我想在三个js上实现裁剪平面。
我对全局剪裁平面不感兴趣,而是对局部剪裁平面感兴趣。
下面是我使用的代码:
switch(this.data.Axis){
case 'X' :
this.clippingplane = new THREE.Plane(new THREE.Vector3(-1 , 0 , 0) , this.data.Slide) ;
break ;
case 'Y' :
this.clippingplane = new THREE.Plane(new THREE.Vector3(0 , -1 , 0) , this.data.Slide) ;
break ;
case 'Z' :
this.clippingplane = new THREE.Plane(new THREE.Vector3(0 , 0 , -1) , this.data.Slide) ;
break ; }
obj.traverseBreadthFirst(function(node){
if(node instanceof THREE.Mesh){
node.material.clipShadows = true ;
node.material.clippingPlanes = [] ;
node.material.clippingPlanes .push( this.clippingplane );
node.material.needsUpdate = true ;
}
});
这里的问题是javascript返回了一个错误:
%t is undefined
对全局剪裁平面使用相同的代码,在渲染器中设置,效果很好...这里有什么问题?
发布于 2018-10-12 08:27:00
尝试此通用方法并将其应用于您的示例
var localPlane = new THREE.Plane( new THREE.Vector3( 0, 0, -1 ), 0.9 );
var material2 = new THREE.PointsMaterial( { size: 0.06, vertexColors: THREE.VertexColors,
clippingPlanes: [ localPlane ],
clipShadows: true
} );
var points2 = new THREE.Points( geometry, material2 );
然后添加你的场景
https://stackoverflow.com/questions/46079724
复制相似问题