upgrade three.js to r125
This commit is contained in:
parent
f5c7692c8d
commit
4dcca770ca
|
@ -9,7 +9,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"skinview-utils": "^0.6.0",
|
||||
"three": "^0.122.0"
|
||||
"three": "^0.125.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
|
@ -3778,9 +3778,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/three": {
|
||||
"version": "0.122.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.122.0.tgz",
|
||||
"integrity": "sha512-bgYMo0WdaQhf7DhLE8OSNN/rVFO5J4K1A2VeeKqoV4MjjuHjfCP6xLpg8Xedhns7NlEnN3sZ6VJROq19Qyl6Sg=="
|
||||
"version": "0.125.2",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.125.2.tgz",
|
||||
"integrity": "sha512-7rIRO23jVKWcAPFdW/HREU2NZMGWPBZ4XwEMt0Ak0jwLUKVJhcKM55eCBWyGZq/KiQbeo1IeuAoo/9l2dzhTXA=="
|
||||
},
|
||||
"node_modules/through": {
|
||||
"version": "2.3.8",
|
||||
|
@ -7118,9 +7118,9 @@
|
|||
}
|
||||
},
|
||||
"three": {
|
||||
"version": "0.122.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.122.0.tgz",
|
||||
"integrity": "sha512-bgYMo0WdaQhf7DhLE8OSNN/rVFO5J4K1A2VeeKqoV4MjjuHjfCP6xLpg8Xedhns7NlEnN3sZ6VJROq19Qyl6Sg=="
|
||||
"version": "0.125.2",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.125.2.tgz",
|
||||
"integrity": "sha512-7rIRO23jVKWcAPFdW/HREU2NZMGWPBZ4XwEMt0Ak0jwLUKVJhcKM55eCBWyGZq/KiQbeo1IeuAoo/9l2dzhTXA=="
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"skinview-utils": "^0.6.0",
|
||||
"three": "^0.122.0"
|
||||
"three": "^0.125.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
|
|
34
src/model.ts
34
src/model.ts
|
@ -1,5 +1,5 @@
|
|||
import { ModelType } from "skinview-utils";
|
||||
import { BoxGeometry, DoubleSide, FrontSide, Group, Mesh, MeshBasicMaterial, Object3D, Texture, Vector2 } from "three";
|
||||
import { BoxGeometry, BufferAttribute, DoubleSide, FrontSide, Group, Mesh, MeshBasicMaterial, Object3D, Texture, Vector2 } from "three";
|
||||
|
||||
function setUVs(box: BoxGeometry, u: number, v: number, width: number, height: number, depth: number, textureWidth: number, textureHeight: number): void {
|
||||
const toFaceVertices = (x1: number, y1: number, x2: number, y2: number) => [
|
||||
|
@ -16,20 +16,16 @@ function setUVs(box: BoxGeometry, u: number, v: number, width: number, height: n
|
|||
const right = toFaceVertices(u + width + depth, v + depth, u + width + depth * 2, v + height + depth);
|
||||
const back = toFaceVertices(u + width + depth * 2, v + depth, u + width * 2 + depth * 2, v + height + depth);
|
||||
|
||||
box.faceVertexUvs[0] = [
|
||||
[right[3], right[0], right[2]],
|
||||
[right[0], right[1], right[2]],
|
||||
[left[3], left[0], left[2]],
|
||||
[left[0], left[1], left[2]],
|
||||
[top[3], top[0], top[2]],
|
||||
[top[0], top[1], top[2]],
|
||||
[bottom[0], bottom[3], bottom[1]],
|
||||
[bottom[3], bottom[2], bottom[1]],
|
||||
[front[3], front[0], front[2]],
|
||||
[front[0], front[1], front[2]],
|
||||
[back[3], back[0], back[2]],
|
||||
[back[0], back[1], back[2]]
|
||||
];
|
||||
const uvAttr = box.attributes.uv as BufferAttribute;
|
||||
uvAttr.copyVector2sArray([
|
||||
right[3], right[2], right[0], right[1],
|
||||
left[3], left[2], left[0], left[1],
|
||||
top[3], top[2], top[0], top[1],
|
||||
bottom[0], bottom[1], bottom[3], bottom[2],
|
||||
front[3], front[2], front[0], front[1],
|
||||
back[3], back[2], back[0], back[1]
|
||||
]);
|
||||
uvAttr.needsUpdate = true;
|
||||
}
|
||||
|
||||
function setSkinUVs(box: BoxGeometry, u: number, v: number, width: number, height: number, depth: number): void {
|
||||
|
@ -129,8 +125,6 @@ export class SkinObject extends Group {
|
|||
rightArmMesh.scale.y = 12;
|
||||
rightArmMesh.scale.z = 4;
|
||||
setSkinUVs(rightArmBox, 40, 16, this.slim ? 3 : 4, 12, 4);
|
||||
rightArmBox.uvsNeedUpdate = true;
|
||||
rightArmBox.elementsNeedUpdate = true;
|
||||
});
|
||||
|
||||
const rightArm2Box = new BoxGeometry();
|
||||
|
@ -140,8 +134,6 @@ export class SkinObject extends Group {
|
|||
rightArm2Mesh.scale.y = 12.5;
|
||||
rightArm2Mesh.scale.z = 4.5;
|
||||
setSkinUVs(rightArm2Box, 40, 32, this.slim ? 3 : 4, 12, 4);
|
||||
rightArm2Box.uvsNeedUpdate = true;
|
||||
rightArm2Box.elementsNeedUpdate = true;
|
||||
});
|
||||
|
||||
const rightArmPivot = new Group();
|
||||
|
@ -166,8 +158,6 @@ export class SkinObject extends Group {
|
|||
leftArmMesh.scale.y = 12;
|
||||
leftArmMesh.scale.z = 4;
|
||||
setSkinUVs(leftArmBox, 32, 48, this.slim ? 3 : 4, 12, 4);
|
||||
leftArmBox.uvsNeedUpdate = true;
|
||||
leftArmBox.elementsNeedUpdate = true;
|
||||
});
|
||||
|
||||
const leftArm2Box = new BoxGeometry();
|
||||
|
@ -177,8 +167,6 @@ export class SkinObject extends Group {
|
|||
leftArm2Mesh.scale.y = 12.5;
|
||||
leftArm2Mesh.scale.z = 4.5;
|
||||
setSkinUVs(leftArm2Box, 48, 48, this.slim ? 3 : 4, 12, 4);
|
||||
leftArm2Box.uvsNeedUpdate = true;
|
||||
leftArm2Box.elementsNeedUpdate = true;
|
||||
});
|
||||
|
||||
const leftArmPivot = new Group();
|
||||
|
|
Loading…
Reference in New Issue