зеркало из https://github.com/mozilla/Spoke.git
Add flag to avoid model combination
This commit is contained in:
Родитель
4dcd7913bb
Коммит
6894f27685
|
@ -126,7 +126,7 @@ export default class MeshCombinationGroup {
|
|||
}
|
||||
|
||||
await asyncTraverse(rootObject, async object => {
|
||||
if (isStatic(object) && object.isMesh) {
|
||||
if (isStatic(object) && object.isMesh && object._combine !== false) {
|
||||
let added = false;
|
||||
|
||||
for (const group of meshCombinationGroups) {
|
||||
|
|
|
@ -28,6 +28,7 @@ export default class KitPieceNode extends EditorNodeMixin(Model) {
|
|||
|
||||
node.collidable = !!json.components.find(c => c.name === "collidable");
|
||||
node.walkable = !!json.components.find(c => c.name === "walkable");
|
||||
node.combine = !!json.components.find(c => c.name === "combine");
|
||||
|
||||
const loopAnimationComponent = json.components.find(c => c.name === "loop-animation");
|
||||
|
||||
|
@ -65,6 +66,7 @@ export default class KitPieceNode extends EditorNodeMixin(Model) {
|
|||
this._canonicalUrl = "";
|
||||
this.collidable = true;
|
||||
this.walkable = true;
|
||||
this.combine = true;
|
||||
this._kitId = null;
|
||||
this._pieceId = null;
|
||||
this.subPieces = [];
|
||||
|
@ -439,6 +441,10 @@ export default class KitPieceNode extends EditorNodeMixin(Model) {
|
|||
components.walkable = {};
|
||||
}
|
||||
|
||||
if (this.combine) {
|
||||
components.combine = {};
|
||||
}
|
||||
|
||||
return super.serialize(components);
|
||||
}
|
||||
|
||||
|
@ -451,6 +457,7 @@ export default class KitPieceNode extends EditorNodeMixin(Model) {
|
|||
this._pieceId = source._pieceId;
|
||||
this.collidable = source.collidable;
|
||||
this.walkable = source.walkable;
|
||||
this.combine = source.combine;
|
||||
|
||||
// TODO update the sub-piece copy method
|
||||
if (this.model) {
|
||||
|
|
|
@ -48,6 +48,7 @@ export default class ModelNode extends EditorNodeMixin(Model) {
|
|||
|
||||
node.collidable = !!json.components.find(c => c.name === "collidable");
|
||||
node.walkable = !!json.components.find(c => c.name === "walkable");
|
||||
node.combine = !!json.components.find(c => c.name === "combine");
|
||||
|
||||
const loopAnimationComponent = json.components.find(c => c.name === "loop-animation");
|
||||
|
||||
|
@ -85,6 +86,7 @@ export default class ModelNode extends EditorNodeMixin(Model) {
|
|||
this._canonicalUrl = "";
|
||||
this.collidable = true;
|
||||
this.walkable = true;
|
||||
this.combine = true;
|
||||
this.initialScale = 1;
|
||||
this.boundingBox = new Box3();
|
||||
this.boundingSphere = new Sphere();
|
||||
|
@ -332,6 +334,10 @@ export default class ModelNode extends EditorNodeMixin(Model) {
|
|||
components.walkable = {};
|
||||
}
|
||||
|
||||
if (this.combine) {
|
||||
components.combine = {};
|
||||
}
|
||||
|
||||
return super.serialize(components);
|
||||
}
|
||||
|
||||
|
@ -351,6 +357,7 @@ export default class ModelNode extends EditorNodeMixin(Model) {
|
|||
this.attribution = source.attribution;
|
||||
this.collidable = source.collidable;
|
||||
this.walkable = source.walkable;
|
||||
this.combine = source.combine;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ export default class Model extends Object3D {
|
|||
this._src = null;
|
||||
this._castShadow = false;
|
||||
this._receiveShadow = false;
|
||||
this._combine = true;
|
||||
this.activeClipIndices = [];
|
||||
this.animationMixer = null;
|
||||
this.currentActions = [];
|
||||
|
@ -53,6 +54,7 @@ export default class Model extends Object3D {
|
|||
|
||||
this.castShadow = this._castShadow;
|
||||
this.receiveShadow = this._receiveShadow;
|
||||
this.combine = this._combine;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -209,6 +211,20 @@ export default class Model extends Object3D {
|
|||
}
|
||||
}
|
||||
|
||||
get combine() {
|
||||
return this._combine;
|
||||
}
|
||||
|
||||
set combine(value) {
|
||||
this._combine = value;
|
||||
|
||||
if (this.model) {
|
||||
this.model.traverse(child => {
|
||||
child._combine = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add play/pause methods for previewing animations.
|
||||
|
||||
copy(source, recursive = true) {
|
||||
|
|
|
@ -122,6 +122,10 @@ export default class KitPieceNodeEditor extends Component {
|
|||
this.props.editor.setPropertySelected("receiveShadow", receiveShadow);
|
||||
};
|
||||
|
||||
onChangeCombine = combine => {
|
||||
this.props.editor.setPropertySelected("combine", combine);
|
||||
};
|
||||
|
||||
isAnimationPropertyDisabled() {
|
||||
const { multiEdit, editor, node } = this.props;
|
||||
|
||||
|
@ -189,6 +193,9 @@ export default class KitPieceNodeEditor extends Component {
|
|||
<InputGroup name="Receive Shadow">
|
||||
<BooleanInput value={node.receiveShadow} onChange={this.onChangeReceiveShadow} />
|
||||
</InputGroup>
|
||||
<InputGroup name="Combine">
|
||||
<BooleanInput value={node.combine} onChange={this.onChangeCombine} />
|
||||
</InputGroup>
|
||||
</NodeEditor>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ export default class ModelNodeEditor extends Component {
|
|||
this.props.editor.setPropertySelected("receiveShadow", receiveShadow);
|
||||
};
|
||||
|
||||
onChangeCombine = combine => {
|
||||
this.props.editor.setPropertySelected("combine", combine);
|
||||
};
|
||||
|
||||
isAnimationPropertyDisabled() {
|
||||
const { multiEdit, editor, node } = this.props;
|
||||
|
||||
|
@ -84,6 +88,9 @@ export default class ModelNodeEditor extends Component {
|
|||
<InputGroup name="Receive Shadow">
|
||||
<BooleanInput value={node.receiveShadow} onChange={this.onChangeReceiveShadow} />
|
||||
</InputGroup>
|
||||
<InputGroup name="Combine">
|
||||
<BooleanInput value={node.combine} onChange={this.onChangeCombine} />
|
||||
</InputGroup>
|
||||
{node.model && <GLTFInfo node={node} />}
|
||||
</NodeEditor>
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче