技術方案:threejs的剖切,是由renderer.clippingPlanes實現的。
this.clipHelpers = new THREE.Group();
this.clipHelpers.add(new THREE.AxesHelper(20));
this.globalPlanes = new THREE.Plane(new THREE.Vector3(1, 0, 0), 0);
this.clipHelpers.add(new THREE.PlaneHelper( this.globalPlanes, 20, 0xff0000));
this.clipHelpers.visible = false;
this.scene.add(this.clipHelpers);
//創建一個剖切面
this.renderer.clippingPlanes = this.globalPlanes; // 顯示剖面
this.renderer.localClippingEnabled = true;
this.globalPlanes.constant = 5;//這個數值的變化將引起剖面的移動
效果如下: