Skip to content

Commit

Permalink
add isBound and bindTime output (x3dom#1325)
Browse files Browse the repository at this point in the history
* add isBound and bindTime output

* Update CHANGELOG.md
  • Loading branch information
andreasplesch authored Aug 28, 2024
1 parent 9d761f6 commit 84a7caf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* MSFT_texture_dds
* field values from metadata for non-standard nodes
* Improvements
* isBound and bindTime output for bindable nodes
* generate module builds (x3dom-modules.js etc.)
* allow null value for glTF.scene.nodes
* improved fog over shadows ([dmorehead](https://github.com/dmorehead))
Expand Down
25 changes: 25 additions & 0 deletions src/nodes/Core/X3DBindableNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ x3dom.registerNodeType(
*/
this.addField_SFBool( ctx, "isActive", false );

/**
* Output event true gets sent when node becomes bound and activated,
* otherwise output event false gets sent when node becomes unbound and deactivated.
* Only appears in messages
* @var {x3dom.fields.SFBool} isBound
* @memberof x3dom.nodeTypes.X3DBindableNode
* @initvalue false
* @field x3d
* @instance
*/

/**
* Event sent reporting timestamp when node becomes active/inactive.
* Only appears in messages
* @var {x3dom.fields.SFTime} bindTime
* @memberof x3dom.nodeTypes.X3DBindableNode
* @initvalue null
* @field x3d
* @instance
*/

this._autoGen = ( ctx && ctx.autoGen ? true : false );
if ( this._autoGen )
{this._vf.description = "default" + this.constructor.superClass._typeName;}
Expand Down Expand Up @@ -88,13 +109,17 @@ x3dom.registerNodeType(
activate : function ( prev )
{
this.postMessage( "isActive", true );
this.postMessage( "isBound", true );
this.postMessage( "bindTime", Date.now() / 1000 );
x3dom.debug.logInfo( "activate " + this.typeName() + "Bindable " +
this._DEF + "/" + this._vf.description );
},

deactivate : function ( prev )
{
this.postMessage( "isActive", false );
this.postMessage( "isBound", false );
this.postMessage( "bindTime", Date.now() / 1000 );
x3dom.debug.logInfo( "deactivate " + this.typeName() + "Bindable " +
this._DEF + "/" + this._vf.description );
},
Expand Down

0 comments on commit 84a7caf

Please sign in to comment.