Referencing in JavaScript
Reference an existing Blocksmith Method
Any Blocksmith event can be referenced in the JavaScript console. For example:
1. Add the following event to an object:
On: Interaction Start
Then: Myself
Run Script
2. Click on the Edit Script button on the event.
3. Write the following script in the new Script Editor window:
this.moveBy (1, 0, 0);
What does this script do? Each time it is activated, the script will move the object by 1 meter along the x-axis in the scene.
4. Play the Viewer and try it out! Does your object move 1 meter each time it is clicked?
Use the Store Variable Concept
- Store a variable to use in another script using the
store.set
command. - Retrieve the stored variable's value using the
store.get
command.