Skip to content

Commit 7c8705e

Browse files
committed
Add needsUpdate property to Material
1 parent 49d76da commit 7c8705e

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

js/scripts/three-class-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ module.exports = {
656656
visible: new Types.Bool(true),
657657
opacity: new Types.Float(1.0),
658658
},
659-
propsDefinedByThree: [ 'type' ]
659+
propsDefinedByThree: [ 'type', 'needsUpdate' ]
660660
},
661661
MeshBasicMaterial: {
662662
relativePath: './materials/MeshBasicMaterial',

js/src/materials/Material.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var _ = require('underscore');
2+
var MaterialAutogen = require('./Material.autogen').MaterialModel;
3+
4+
var MaterialModel = MaterialAutogen.extend({
5+
6+
onCustomMessage: function(content, buffers) {
7+
switch(content.type) {
8+
case 'needsUpdate':
9+
this.obj.needsUpdate = true;
10+
this.trigger('childchange', this);
11+
break;
12+
default:
13+
MaterialAutogen.prototype.onCustomMessage.call(arguments);
14+
15+
}
16+
},
17+
18+
});
19+
20+
module.exports = {
21+
MaterialModel: MaterialModel,
22+
};

pythreejs/materials/Material.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
from traitlets import Bool, validate
3+
from .Material_autogen import Material as MaterialAutogen
4+
5+
6+
class Material(MaterialAutogen):
7+
8+
# Do not sync this automatically:
9+
needsUpdate = Bool(False)
10+
11+
@validate('needsUpdate')
12+
def onNeedsUpdate(self, proposal):
13+
if proposal.value:
14+
content = {
15+
"type": "needsUpdate",
16+
}
17+
self.send(content=content, buffers=None)
18+
# Never actually set value
19+
return False

0 commit comments

Comments
 (0)