|
@@ -30,7 +30,8 @@ export default {
|
|
|
let comlist = list.filter(it=>it.spaceType!=14);
|
|
|
this.loaderCommonSpace(this.gltfSpaceUrl,comlist,1);
|
|
|
let arrlist = list.filter(it=>it.spaceType==14);
|
|
|
- this.loaderCommonSpace(this.gltfSpace1Url,arrlist,2);
|
|
|
+
|
|
|
+ this.loaderGraseSpace(list);
|
|
|
},
|
|
|
loaderCommonSpace(gltfSpaceUrl,list,type=1){
|
|
|
var that = this;
|
|
@@ -117,6 +118,55 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+ loaderGraseSpace(list){
|
|
|
+ let glbWidth = 300;
|
|
|
+ let glbHeight = 300;
|
|
|
+ var that = this;
|
|
|
+ console.log("草地模型加载成功",list)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ list && list.forEach(obj=>{
|
|
|
+ let positionX = obj.centerX / 100;
|
|
|
+ let positionY = obj.centerY / 100;
|
|
|
+ let scaleX = obj.spaceWidth / 100;
|
|
|
+ let scaleY = obj.spaceHeight / 100;
|
|
|
+
|
|
|
+ let texture = new THREE.TextureLoader().load( "https://dm.static.elab-plus.com/miniProgram/grass.jpg");
|
|
|
+ texture.wrapS = THREE.RepeatWrapping;
|
|
|
+ texture.wrapT = THREE.RepeatWrapping;
|
|
|
+
|
|
|
+ texture.repeat.set(scaleX, scaleY);
|
|
|
+
|
|
|
+ let geometry = new THREE.PlaneGeometry(obj.spaceWidth/100, obj.spaceHeight/100);
|
|
|
+ let material = new THREE.MeshBasicMaterial({ map: texture });
|
|
|
+ let cube = new THREE.Mesh(geometry, material);
|
|
|
+
|
|
|
+ cube.name= "地板";
|
|
|
+ cube.userType = "mesh";
|
|
|
+ cube.userData = obj;
|
|
|
+
|
|
|
+ cube.position.set(positionX, -0.001, -positionY);
|
|
|
+ cube.rotation.x = -Math.PI / 2 ;
|
|
|
+ cube.receiveShadow = true;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ that.scene.add(cube);
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
changeSpacesAnimOld(curSpace){
|
|
|
|
|
@@ -178,76 +228,100 @@ export default {
|
|
|
let toPz = curSpace.toPz;
|
|
|
let toScaleX = curSpace.toScaleX;
|
|
|
let toScaleZ = curSpace.toScaleZ;
|
|
|
-
|
|
|
- let spaceInitMatrix = [];
|
|
|
- cube.instancedMeshIndexList.forEach(instanced=>{
|
|
|
- let _index = instanced.instancedMeshIndex;
|
|
|
- let instancedMesh = this.instancedSpaceMeshList[_index];
|
|
|
- let startMatrix = new THREE.Matrix4();
|
|
|
- instancedMesh.getMatrixAt(instanced.instancedAtIndex,startMatrix);
|
|
|
- spaceInitMatrix.push({
|
|
|
- index:_index,
|
|
|
- matrix:startMatrix.clone(),
|
|
|
- color:instancedMesh.material.color.clone(),
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- var tween = new TWEEN.Tween({
|
|
|
- x: cube.position.x,
|
|
|
- z: cube.position.z,
|
|
|
- sx:cube.scale.x,
|
|
|
- sz:cube.scale.z
|
|
|
- })
|
|
|
- .to({
|
|
|
- x: curSpace.toPx,
|
|
|
- z: curSpace.toPz,
|
|
|
- sx:curSpace.toScaleX,
|
|
|
- sz:curSpace.toScaleZ
|
|
|
- }, 2000)
|
|
|
- .easing(TWEEN.Easing.Quadratic.InOut)
|
|
|
- .onUpdate((object)=> {
|
|
|
-
|
|
|
+ if(cube.instancedMeshIndexList){
|
|
|
+ let spaceInitMatrix = [];
|
|
|
cube.instancedMeshIndexList.forEach(instanced=>{
|
|
|
- let _index = instanced.instancedMeshIndex;
|
|
|
+ let _index = instanced.instancedMeshIndex;
|
|
|
let instancedMesh = this.instancedSpaceMeshList[_index];
|
|
|
-
|
|
|
- let tmp = spaceInitMatrix.find(it=>it.index==_index);
|
|
|
- let stratMatrix = tmp.matrix.clone();
|
|
|
- let scaleMatrix = new THREE.Matrix4();
|
|
|
- let panMatrix = new THREE.Matrix4();
|
|
|
-
|
|
|
- scaleMatrix.makeScale(object.sx / scaleX,1,object.sz / scaleZ);
|
|
|
- panMatrix.makeTranslation(object.x - x,0,object.z - z);
|
|
|
- stratMatrix.multiply(scaleMatrix).premultiply(panMatrix);
|
|
|
- instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
- instancedMesh.setMatrixAt(instanced.instancedAtIndex,stratMatrix);
|
|
|
- if(this.curSpaceObj.spaceId==cube.spaceId){
|
|
|
- instancedMesh.instanceColor.needsUpdate = true;
|
|
|
- let color = new THREE.Color(0xFF9F40);
|
|
|
-
|
|
|
- instancedMesh.setColorAt(instanced.instancedAtIndex, color);
|
|
|
- }
|
|
|
+ let startMatrix = new THREE.Matrix4();
|
|
|
+ instancedMesh.getMatrixAt(instanced.instancedAtIndex,startMatrix);
|
|
|
+ spaceInitMatrix.push({
|
|
|
+ index:_index,
|
|
|
+ matrix:startMatrix.clone(),
|
|
|
+ color:instancedMesh.material.color.clone(),
|
|
|
+ })
|
|
|
});
|
|
|
- }).onComplete(()=>{
|
|
|
- this.tweenCameraAnmaChange(false);
|
|
|
- console.warn("***changeSpacesAnim-over***")
|
|
|
- if(this.curSpaceObj.spaceId==cube.spaceId){
|
|
|
+
|
|
|
+ var tween = new TWEEN.Tween({
|
|
|
+ x: cube.position.x,
|
|
|
+ z: cube.position.z,
|
|
|
+ sx:cube.scale.x,
|
|
|
+ sz:cube.scale.z
|
|
|
+ })
|
|
|
+ .to({
|
|
|
+ x: curSpace.toPx,
|
|
|
+ z: curSpace.toPz,
|
|
|
+ sx:curSpace.toScaleX,
|
|
|
+ sz:curSpace.toScaleZ
|
|
|
+ }, 2000)
|
|
|
+ .easing(TWEEN.Easing.Quadratic.InOut)
|
|
|
+ .onUpdate((object)=> {
|
|
|
+
|
|
|
cube.instancedMeshIndexList.forEach(instanced=>{
|
|
|
- let _index = instanced.instancedMeshIndex;
|
|
|
+ let _index = instanced.instancedMeshIndex;
|
|
|
let instancedMesh = this.instancedSpaceMeshList[_index];
|
|
|
+
|
|
|
let tmp = spaceInitMatrix.find(it=>it.index==_index);
|
|
|
- instancedMesh.instanceColor.needsUpdate = true;
|
|
|
- instancedMesh.setColorAt(instanced.instancedAtIndex, tmp.color);
|
|
|
+ let stratMatrix = tmp.matrix.clone();
|
|
|
+ let scaleMatrix = new THREE.Matrix4();
|
|
|
+ let panMatrix = new THREE.Matrix4();
|
|
|
+
|
|
|
+ scaleMatrix.makeScale(object.sx / scaleX,1,object.sz / scaleZ);
|
|
|
+ panMatrix.makeTranslation(object.x - x,0,object.z - z);
|
|
|
+ stratMatrix.multiply(scaleMatrix).premultiply(panMatrix);
|
|
|
+ instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
+ instancedMesh.setMatrixAt(instanced.instancedAtIndex,stratMatrix);
|
|
|
+ if(this.curSpaceObj.spaceId==cube.spaceId){
|
|
|
+ instancedMesh.instanceColor.needsUpdate = true;
|
|
|
+ let color = new THREE.Color(0xFF9F40);
|
|
|
+
|
|
|
+ instancedMesh.setColorAt(instanced.instancedAtIndex, color);
|
|
|
+ }
|
|
|
});
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- tween.start();
|
|
|
- this.tweenCameraAnmaChange(true)
|
|
|
- cube.position.x = curSpace.toPx;
|
|
|
- cube.position.z = curSpace.toPz;
|
|
|
- cube.scale.x = curSpace.toScaleX;
|
|
|
- cube.scale.z = curSpace.toScaleZ;
|
|
|
+ }).onComplete(()=>{
|
|
|
+ this.tweenCameraAnmaChange(false);
|
|
|
+ console.warn("***changeSpacesAnim-over***")
|
|
|
+ if(this.curSpaceObj.spaceId==cube.spaceId){
|
|
|
+ cube.instancedMeshIndexList.forEach(instanced=>{
|
|
|
+ let _index = instanced.instancedMeshIndex;
|
|
|
+ let instancedMesh = this.instancedSpaceMeshList[_index];
|
|
|
+ let tmp = spaceInitMatrix.find(it=>it.index==_index);
|
|
|
+ instancedMesh.instanceColor.needsUpdate = true;
|
|
|
+ instancedMesh.setColorAt(instanced.instancedAtIndex, tmp.color);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ tween.start();
|
|
|
+ this.tweenCameraAnmaChange(true)
|
|
|
+ cube.position.x = curSpace.toPx;
|
|
|
+ cube.position.z = curSpace.toPz;
|
|
|
+ cube.scale.x = curSpace.toScaleX;
|
|
|
+ cube.scale.z = curSpace.toScaleZ;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ var tween = new TWEEN.Tween({
|
|
|
+ x: scaleX,
|
|
|
+ z: scaleZ,
|
|
|
+ px:x,
|
|
|
+ pz:z,
|
|
|
+ })
|
|
|
+ .to({
|
|
|
+ x: toScaleX,
|
|
|
+ z: toScaleZ,
|
|
|
+ px:toPx,
|
|
|
+ pz:toPz,
|
|
|
+ }, 2000)
|
|
|
+ .easing(TWEEN.Easing.Quadratic.InOut)
|
|
|
+ .onUpdate((object)=> {
|
|
|
+ cube.scale.x = object.x;
|
|
|
+ cube.scale.z = object.z;
|
|
|
+ cube.position.x = object.px;
|
|
|
+ cube.position.z = object.pz;
|
|
|
+ });
|
|
|
+
|
|
|
+ tween.start();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
allSpaceScale(){
|