Skip to content

Commit 707a1cc

Browse files
function to toggle visibility at position
1 parent b963c60 commit 707a1cc

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/model/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,30 @@ let renderModel = function (modelRender, model, textures, textureNames, type, na
578578
})
579579
};
580580

581+
function setVisibilityAt(x, y, z, visible) {
582+
let info = this.instancePositionMap[x + "_" + y + "_" + z];
583+
if (info) {
584+
let instance = instanceCache[info.key];
585+
if (instance && instance.instance) {
586+
let mesh = instance.instance;
587+
let newScale;
588+
if (visible) {
589+
if (info.scale) {
590+
newScale = info.scale;
591+
} else {
592+
newScale = [1, 1, 1];
593+
}
594+
} else {
595+
newScale = [0, 0, 0];
596+
}
597+
let _v3s = new THREE.Vector3();
598+
mesh.setScaleAt(info.index, _v3s.set(newScale[0], newScale[1], newScale[2]));
599+
}
600+
}
601+
}
602+
603+
ModelRender.prototype.setVisibilityAt = setVisibilityAt;
604+
581605
let createDot = function (c) {
582606
let dotGeometry = new THREE.Geometry();
583607
dotGeometry.vertices.push(new THREE.Vector3());

0 commit comments

Comments
 (0)