Skip to content

Commit

Permalink
Update threejs to latest (bs-community#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore authored Sep 29, 2023
1 parent a930d0c commit 50eadf8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h1>Viewport</h1>

<div class="control-section">
<h1>Light</h1>
<label class="control">Global: <input id="global_light" type="number" value="0.40" step="0.01" min="0.00" max="2.00" size="4"></label>
<label class="control">Global: <input id="global_light" type="number" value="3" step="0.01" min="0.00" max="2.00" size="4"></label>
<label class="control">Camera: <input id="camera_light" type="number" value="0.60" step="0.01" min="0.00" max="2.00" size="4"></label>
</div>

Expand Down
31 changes: 9 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skinview3d",
"version": "3.0.0",
"version": "3.0.1",
"description": "Three.js powered Minecraft skin viewer",
"main": "libs/skinview3d.js",
"type": "module",
Expand Down Expand Up @@ -42,10 +42,9 @@
"dependencies": {
"@types/three": "^0.142.0",
"skinview-utils": "^0.7.1",
"three": "^0.142.0"
"three": "^0.156.1"
},
"devDependencies": {
"@gplane/tsconfig": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@swc/core": "^1.3.53",
"@typescript-eslint/eslint-plugin": "^5.59.0",
Expand Down
44 changes: 18 additions & 26 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,24 @@ function setUVs(
const back = toFaceVertices(u + width + depth * 2, v + depth, u + width * 2 + depth * 2, v + height + depth);

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],
]);
const uvRight = [right[3], right[2], right[0], right[1]];
const uvLeft = [left[3], left[2], left[0], left[1]];
const uvTop = [top[3], top[2], top[0], top[1]];
const uvBottom = [bottom[0], bottom[1], bottom[3], bottom[2]];
const uvFront = [front[3], front[2], front[0], front[1]];
const uvBack = [back[3], back[2], back[0], back[1]];

// Create a new array to hold the modified UV data
const newUVData = [];

// Iterate over the arrays and copy the data to uvData
for (const uvArray of [uvRight, uvLeft, uvTop, uvBottom, uvFront, uvBack]) {
for (const uv of uvArray) {
newUVData.push(uv.x, uv.y);
}
}

uvAttr.set(new Float32Array(newUVData));
uvAttr.needsUpdate = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class SkinViewer {
*/
readonly playerWrapper: Group;

readonly globalLight: AmbientLight = new AmbientLight(0xffffff, 0.4);
readonly globalLight: AmbientLight = new AmbientLight(0xffffff, 3);
readonly cameraLight: PointLight = new PointLight(0xffffff, 0.6);

readonly composer: EffectComposer;
Expand Down
27 changes: 24 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
{
"extends": "@gplane/tsconfig",
"compilerOptions": {
"target": "es2019",
"outDir": "libs",
"noUncheckedIndexedAccess": false
"allowJs": false,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"newLine": "LF",
"noEmitOnError": true,
"noUncheckedIndexedAccess": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"stripInternal": true,
"target": "es2021",
"useDefineForClassFields": true
},
"include": ["src"]
}

0 comments on commit 50eadf8

Please sign in to comment.