added model-link, adjusted sandbox cam

This commit is contained in:
Leon van Kammen 2023-05-08 12:46:33 +02:00
parent c381d25919
commit 297c448dfe
4 changed files with 21 additions and 4 deletions

View file

@ -628,6 +628,7 @@ xrfragment.parseModel = function(model,url){
xrfragment.model[file] = model xrfragment.model[file] = model
model.scene.traverse( (mesh) => { model.scene.traverse( (mesh) => {
console.log("| "+mesh.name)
if( mesh.userData ){ if( mesh.userData ){
let frag = {} let frag = {}
for( let k in mesh.userData ){ for( let k in mesh.userData ){

View file

@ -73,7 +73,7 @@ input[type="submit"] {
a#source{ a#source{
position: absolute; position: absolute;
bottom: 31px; bottom: 29px;
right: 20px; right: 20px;
color: #888; color: #888;
font-weight: bold; font-weight: bold;
@ -82,6 +82,17 @@ a#source{
z-index:2000; z-index:2000;
} }
a#model{
position: absolute;
bottom: 29px;
right: 130px;
color: #888;
font-weight: bold;
font-family: sans-serif;
text-decoration: underline;
z-index:2000;
}
.render { .render {
position:absolute; position:absolute;
top:0; top:0;

View file

@ -20,6 +20,7 @@
</datalist> </datalist>
</div> </div>
<a id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment/blob/main/example/threejs/sandbox/index.html#L92-L112">sourcecode</a> <a id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment/blob/main/example/threejs/sandbox/index.html#L92-L112">sourcecode</a>
<a id="model" target="_blank" href="">⬇️ model</a>
<textarea style="display:none"></textarea> <textarea style="display:none"></textarea>
<script async src="./../../assets/alpine.min.js"></script> <script async src="./../../assets/alpine.min.js"></script>
@ -67,7 +68,6 @@
}; };
init(); init();
animate();
function init() { function init() {
@ -148,7 +148,10 @@
render(); render();
}; };
loader.load( 'example2.gltf#pos=0,1,2', loadGLTF );
let file = 'example2.gltf#pos=0,1,2'
$('#model').setAttribute("href","./../../asset/"+file)
loader.load( file, loadGLTF );
// setup mouse controls // setup mouse controls
@ -164,7 +167,7 @@
controls.maxPolarAngle = Math.PI / 2; controls.maxPolarAngle = Math.PI / 2;
controls.target = new THREE.Vector3(0,1.6,0) controls.target = new THREE.Vector3(0,1.6,0)
camera.position.set( 0, 1.6, 1.5 ); camera.position.set( 0, 1.6, 10 );
controls.update() controls.update()
const geometry = new THREE.BufferGeometry(); const geometry = new THREE.BufferGeometry();
@ -271,6 +274,7 @@
statsMesh.material.map.update(); statsMesh.material.map.update();
} }
animate();
</script> </script>
</body> </body>

View file

@ -33,6 +33,7 @@ xrfragment.parseModel = function(model,url){
xrfragment.model[file] = model xrfragment.model[file] = model
model.scene.traverse( (mesh) => { model.scene.traverse( (mesh) => {
console.log("| "+mesh.name)
if( mesh.userData ){ if( mesh.userData ){
let frag = {} let frag = {}
for( let k in mesh.userData ){ for( let k in mesh.userData ){