Skip to content

Commit 74705b6

Browse files
authored
Merge pull request #4 from donmccurdy/feat-stl-to-zup
feat: Change .STL viewer and samples to +Z=Up
2 parents a177268 + 5f0dade commit 74705b6

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

index.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,15 @@ <h1>Prototype Viewer MediaWiki 3D</h1>
203203
object.position.y -= center.y;
204204
object.position.z -= center.z;
205205

206-
// In GLB, Y-Up is required. In STL it's unclear, but likely that
207-
// Y-Up is typical, though Z-Up is also common. three.js controls
208-
// mostly assume Y-Up. To apply a Z-Up to Y-Up conversion:
209-
// object.set( - Math.PI / 2, 0, 0 );
206+
// In glTF, +Y=Up is required. In STL it's unclear, but for backward-
207+
// compatibility we keep +Z=Up. Because some three.js features assume
208+
// +Y=Up, apply a +Z to +Y conversion for STL.
209+
if (this.modeltype === 'stl') {
210+
const parent = new THREE.Object3D();
211+
parent.rotation.set(- Math.PI / 2, 0, 0);
212+
parent.add(object);
213+
object = parent;
214+
}
210215

211216
// Prevent controls from dollying out farther than 10x size.
212217
this.controls.maxDistance = size * 10;
0 Bytes
Binary file not shown.

models/ganesha_stl.stl

-8.28 MB
Binary file not shown.

models/stl_lion.stl

-8.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)