You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-2Lines changed: 30 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -262,14 +262,20 @@ Create a file named "Viewing.Extension.Workshop.js" (for example), and save it i
262
262
Viewing.Extension.Workshop);
263
263
264
264
265
+
You can also checkout the changes of this step from github by running following command if you have git installed:
266
+
267
+
git checkout workshop-viewer-customization-step1
268
+
265
269
### Step 2 – Reference the extension script
266
270
267
271
Reference the extension file in your index.html by adding the following script element to the header (change the path if you installed the file anywhere other than the www subfolder):
You can also checkout the changes of this step from github by running following command if you have git installed:
272
277
278
+
git checkout workshop-viewer-customization-step2
273
279
274
280
### Step 3 – Load the extension in the viewer
275
281
@@ -314,6 +320,10 @@ and add the event handler immediately before this line of code, then add a metho
314
320
315
321
Note: If you copy the modified index.js file from the Step 3 folder in the tutorial [repository](https://github.com/Developer-Autodesk/tutorial-getting.started-view.and.data), make sure you edit the defaultURN on line 18 to use the URN of the translated file you created at the beginning of the tutorial.
316
322
323
+
You can also checkout the changes of this step from github by running following command if you have git installed:
324
+
325
+
git checkout workshop-viewer-customization-step3
326
+
317
327
### Step 4 – Testing the extension
318
328
319
329
Your barebones extension should be ready to run now. All it does is display an alert when it's loaded. Test that the extension is loaded properly by running your sample. (Remember that you setup your node.js project to serve the client page to [http://localhost:3000/](http://localhost:3000/), so open your WebGL-enabled browser and type that address in the address bar). Since all our changes are on client side, you can just refresh your browser to test your changes.
@@ -362,10 +372,16 @@ Start by adding a handler for the SELECTION_CHANGED event to the Extension (i.e.
362
372
</b>
363
373
</pre>
364
374
375
+
376
+
You can also checkout the changes of this step from github by running following command if you have git installed:
377
+
378
+
git checkout workshop-viewer-customization-step5
379
+
365
380
Every element in the displayed model has a unique ID called a dbId. The code you've just written simply stores the dbId of the first element in the list of elements that the user selected. (Usually, the user will only select a single element, but more complete code would handle multiple selected elements).
366
381
367
382
You can test your code now, if you like. Put a breakpoint in the event handler to check its being called when you select an element. You can use Developer Tool of Chrome or similar tools in other modern browsers to do debugging like setting breaking point, watch variable values, etc. (Hint: You select a model element by clicking it with you mouse; elements are highlighted in blue when selected).
368
383
384
+
369
385
### Step 6 – Displaying a panel
370
386
371
387
Now we'll get properties of selected component and display them in a custom viewer panel. Using the viewer UI to create your extensions will help migrating code from one project to another. It helps making your extension non-dependent of the client. However, you can manipulate any other component of your web application from the extension – you could read or write information stored in a separate database, or update a table somewhere else on the webpage., etc, etc.
@@ -501,6 +517,13 @@ Replace the implementation of the selection handler with the following code, so
501
517
}
502
518
503
519
</pre>
520
+
521
+
522
+
You can also checkout the changes of this step from github by running following command if you have git installed:
523
+
524
+
git checkout workshop-viewer-customization-step6
525
+
526
+
504
527
You've now finished writing your extension to respond to a user selecting a model element by displaying that element's properties in a panel and isolating that element in the view. Launch the client page and select a model element by clicking on it. The model and camera view reset if you clear your selection or click in space.
505
528
506
529
### Step 7 (Bonus step) – Moving the camera
@@ -618,6 +641,11 @@ Finally modify the selection handler to trigger the animation when a component i
618
641
619
642
620
643
</pre>
644
+
645
+
You can also checkout the changes of this step from github by running following command if you have git installed:
646
+
647
+
git checkout workshop-viewer-customization-step7
648
+
621
649
Test your extension again. This time, in addition to displaying the panel, the camera (your view of the model) starts rotating when you select a model element.
0 commit comments