-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update rhino3dm js userstrings example
- Loading branch information
Showing
3 changed files
with
4 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ | |
"three": "https://unpkg.com/[email protected]/build/three.module.js", | ||
"three/examples/jsm/controls/OrbitControls": "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js", | ||
"three/examples/jsm/loaders/3DMLoader": "https://unpkg.com/[email protected]/examples/jsm/loaders/3DMLoader.js", | ||
"rhino3dm":"https://unpkg.com/[email protected]beta2/rhino3dm.module.min.js" | ||
"rhino3dm":"https://unpkg.com/[email protected]beta3/rhino3dm.module.min.js" | ||
} | ||
} | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,11 @@ import { Rhino3dmLoader } from 'three/examples/jsm/loaders/3DMLoader' | |
import rhino3dm from 'rhino3dm' | ||
|
||
const model = 'RectifiedArchimedeanSolids.3dm' | ||
let rotation = 0.01 | ||
let rotation = 0.001 | ||
const selectMaterial = new THREE.MeshStandardMaterial( { metalness: 1, roughness: 0.7, color: 0xffff00 } ) | ||
const material = new THREE.MeshStandardMaterial( { metalness: 1, roughness: 0.7, color: 0xadd8e6 } ) | ||
|
||
window.addEventListener( 'click', handleInteraction, false) | ||
window.addEventListener( 'mousemove', handleInteraction, false) | ||
window.addEventListener( 'touchstart', handleInteraction, false) | ||
|
||
// globals | ||
|
@@ -22,7 +21,6 @@ const rhino = await rhino3dm() | |
init() | ||
load() | ||
|
||
|
||
async function load() { | ||
|
||
const res = await fetch(model) | ||
|
@@ -61,7 +59,7 @@ async function load() { | |
|
||
// load and pass to threejs | ||
const loader = new Rhino3dmLoader() | ||
loader.setLibraryPath( 'https://unpkg.com/[email protected]beta2/' ) | ||
loader.setLibraryPath( 'https://unpkg.com/[email protected]beta3/' ) | ||
|
||
loader.load( model, function ( object ) { | ||
|
||
|
@@ -133,14 +131,9 @@ function handleInteraction( event ) { | |
if ( event.type === 'click' ) { | ||
coordinates = { x: event.clientX, y: event.clientY } | ||
} | ||
else if ( event.type === 'mousemove' ) { | ||
rotation = Math.abs( 1 - ( event.clientX / ( window.innerWidth / 2 ) ) ) / 10 | ||
return | ||
} | ||
} else if ( event instanceof TouchEvent ) { | ||
if ( event.type === 'touchstart' ) { | ||
coordinates = { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY } | ||
rotation = Math.abs( 1 - ( event.changedTouches[0].clientX / ( window.innerWidth / 2 ) ) ) / 10 | ||
} | ||
} | ||
onClick( coordinates ) | ||
|