How do I load and add multiple models to a AR threex-artoolkit scene?How do I add a class to a given element?How can I select an element with multiple classes in jQuery?How can I add a key/value pair to a JavaScript object?How can I add new array elements at the beginning of an array in Javascript?Animating Canvas Billboard in THREE.jsUnderstanding accessing a model loaded into three.js with a 'global variable' using a spotlight as an examplecanceling loading an object into a scene in THREE.jsThree js memory leak on CubeTextureLoader .loadHow do I add a div inside a THREE.js sceneJavascript local variable lifetime
Are there any to-scale diagrams of the TRAPPIST-1 system?
Units in general relativity
Why did the population of Bhutan drop by 70% between 2007 and 2008?
Videos of surgery
How do I insert two edge loops equally spaced from the edges?
Is the internet in Madagascar faster than in UK?
Book featuring a child learning from a crowdsourced AI book
Counting the triangles that can be formed from segments of given lengths
Why did James Cameron decide to give Alita big eyes?
Are (c#) dictionaries an Anti Pattern?
Why does matter stay collapsed in the core, following a supernova explosion?
Availability Groups automatic failover is not so automatic
How could a self contained organic body propel itself in space
How to force GCC to assume that a floating-point expression is non-negative?
how to write a complete text using calligraphic fonts?
Is there a word or phrase that means "use other people's wifi or Internet service without consent"?
If I said I had $100 when asked, but I actually had $200, would I be lying by omission?
Could the UK amend the European Withdrawal Act and revoke the Article 50 invocation?
Find most "academic" implementation of doubly linked list
Is there a difference between 辞典 and 辞書 ?
Term used to describe a person who predicts future outcomes
Can I get a PhD for developing an educational software?
How to prevent a hosting company from accessing a VM's encryption keys?
Is it true that different variants of the same model aircraft don't require pilot retraining?
How do I load and add multiple models to a AR threex-artoolkit scene?
How do I add a class to a given element?How can I select an element with multiple classes in jQuery?How can I add a key/value pair to a JavaScript object?How can I add new array elements at the beginning of an array in Javascript?Animating Canvas Billboard in THREE.jsUnderstanding accessing a model loaded into three.js with a 'global variable' using a spotlight as an examplecanceling loading an object into a scene in THREE.jsThree js memory leak on CubeTextureLoader .loadHow do I add a div inside a THREE.js sceneJavascript local variable lifetime
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
For this project I'm trying to create a AR scene where different markers will display different models.
I'm able to load and add a .DAE model using the Collada loader and as expected, when the user goes on the website the browser asks for the user's permission to use the camera.
This is achieved by using, as I said earlier, the ColladaLoader, adding the model to a variable called model1, scaling it and then calling the init function.
This init function creates a renderer, creates a scene and adds a camera etc, handles browser resize and adds the model markers.
Since adding the one model worked I thought to add more I could just copy and paste this colladaloader and point it to a different model and set a new marker for it. This fortunately works however when I visit the website on mobile it is incredibly sluggish and asks for my permission to use the camera 7/8 times (as many times as I have loaded models). This is due to, I think, after each model is loaded they all make a call to the init function. So it creates and adds as many scenes, cameras, renders etc as there are models.
Inspecting the page you can see there is a new canvas element for each model when there should be just one.
<script type="text/javascript">
var model1, axe, tree, sword, planks, minerals;
var loader = new THREE.ColladaLoader();
loader.load('greathallnow.DAE', function(collada)
model1 = collada.scene;
model1.scale.x = model1.scale.y = model1.scale.z = 0.5;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('axeyes.dae', function(collada)
axe = collada.scene;
axe.scale.x = axe.scale.y = axe.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('tree.dae', function(collada)
tree = collada.scene;
tree.scale.x = tree.scale.y = tree.scale.z = 0.01;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('swordplz.dae', function(collada)
sword = collada.scene;
sword.scale.x = sword.scale.y = sword.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('planks.dae', function(collada)
planks = collada.scene;
planks.scale.x = planks.scale.y = planks.scale.z = 0.05;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('stoneblockplural.dae', function(collada)
minerals = collada.scene;
minerals.scale.x = minerals.scale.y = minerals.scale.z = 0.25;
init();
);
function init()
// init renderer
var renderer = new THREE.WebGLRenderer(
antialias: true,
alpha: true
);
renderer.setClearColor(new THREE.Color('lightgrey'), 0)
renderer.setSize(640, 480);
renderer.domElement.style.position = 'absolute'
renderer.domElement.style.top = '0px'
renderer.domElement.style.left = '0px'
document.body.appendChild(renderer.domElement);
// array of functions for the rendering loop
var onRenderFcts = [];
// init scene and camera
var scene = new THREE.Scene();
// Create a camera
var camera = new THREE.Camera();
scene.add(camera);
var light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1);
scene.add(light);
var arToolkitSource = new THREEx.ArToolkitSource(
sourceType: 'webcam'
);
arToolkitSource.init(function onReady()
onResize()
);
// handle resize
window.addEventListener('resize', function()
onResize()
);
function onResize()
arToolkitSource.onResize()
arToolkitSource.copySizeTo(renderer.domElement)
if (arToolkitContext.arController !== null)
arToolkitSource.copySizeTo(arToolkitContext.arController.canvas)
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext(
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'data/camera_para.dat',
detectionMode: 'mono',
)
// initialize it
arToolkitContext.init(function onCompleted()
// copy projection matrix to camera
camera.projectionMatrix.copy(arToolkitContext.getProjectionMatrix());
)
// update artoolkit on every frame
onRenderFcts.push(function()
if (arToolkitSource.ready === false) return
arToolkitContext.update(arToolkitSource.domElement)
)
var markerRoot = new THREE.Group;
scene.add(markerRoot);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/ghall-marker.patt',
);
var markerRoot2 = new THREE.Group;
scene.add(markerRoot2);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot2,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/axe.patt',
);
var markerRoot3 = new THREE.Group;
scene.add(markerRoot3);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot3,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/tree.patt', );
var markerRoot4 = new THREE.Group;
scene.add(markerRoot4);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot4,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/sword.patt', );
var markerRoot5 = new THREE.Group;
scene.add(markerRoot5);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot5,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/planks.patt', );
var markerRoot6 = new THREE.Group;
scene.add(markerRoot6);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot6,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/minerals.patt', );
markerRoot.add(model1);
markerRoot2.add(axe);
markerRoot3.add(tree);
markerRoot4.add(sword);
markerRoot5.add(planks);
markerRoot6.add(minerals);
// render the scene
onRenderFcts.push(function()
renderer.render(scene, camera);
)
// run the rendering loop
var lastTimeMsec = null
requestAnimationFrame(function animate(nowMsec) );
</script>
I don't think each model needs to make a call to the init function, instead I think they should all be loaded and then there is only one init() which adds them all to the scene and renders them all. This would hopefully improve performance as well. I'm just not sure how to go about this?
You can see the issue I'm having if you visit https://arevisit.madamot.com
Or you can see what currently happens in this YouTube video
https://youtu.be/DjJdsBtfgvM
Many thanks,
Adam
javascript three.js collada artoolkit jsartoolkit
add a comment |
For this project I'm trying to create a AR scene where different markers will display different models.
I'm able to load and add a .DAE model using the Collada loader and as expected, when the user goes on the website the browser asks for the user's permission to use the camera.
This is achieved by using, as I said earlier, the ColladaLoader, adding the model to a variable called model1, scaling it and then calling the init function.
This init function creates a renderer, creates a scene and adds a camera etc, handles browser resize and adds the model markers.
Since adding the one model worked I thought to add more I could just copy and paste this colladaloader and point it to a different model and set a new marker for it. This fortunately works however when I visit the website on mobile it is incredibly sluggish and asks for my permission to use the camera 7/8 times (as many times as I have loaded models). This is due to, I think, after each model is loaded they all make a call to the init function. So it creates and adds as many scenes, cameras, renders etc as there are models.
Inspecting the page you can see there is a new canvas element for each model when there should be just one.
<script type="text/javascript">
var model1, axe, tree, sword, planks, minerals;
var loader = new THREE.ColladaLoader();
loader.load('greathallnow.DAE', function(collada)
model1 = collada.scene;
model1.scale.x = model1.scale.y = model1.scale.z = 0.5;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('axeyes.dae', function(collada)
axe = collada.scene;
axe.scale.x = axe.scale.y = axe.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('tree.dae', function(collada)
tree = collada.scene;
tree.scale.x = tree.scale.y = tree.scale.z = 0.01;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('swordplz.dae', function(collada)
sword = collada.scene;
sword.scale.x = sword.scale.y = sword.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('planks.dae', function(collada)
planks = collada.scene;
planks.scale.x = planks.scale.y = planks.scale.z = 0.05;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('stoneblockplural.dae', function(collada)
minerals = collada.scene;
minerals.scale.x = minerals.scale.y = minerals.scale.z = 0.25;
init();
);
function init()
// init renderer
var renderer = new THREE.WebGLRenderer(
antialias: true,
alpha: true
);
renderer.setClearColor(new THREE.Color('lightgrey'), 0)
renderer.setSize(640, 480);
renderer.domElement.style.position = 'absolute'
renderer.domElement.style.top = '0px'
renderer.domElement.style.left = '0px'
document.body.appendChild(renderer.domElement);
// array of functions for the rendering loop
var onRenderFcts = [];
// init scene and camera
var scene = new THREE.Scene();
// Create a camera
var camera = new THREE.Camera();
scene.add(camera);
var light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1);
scene.add(light);
var arToolkitSource = new THREEx.ArToolkitSource(
sourceType: 'webcam'
);
arToolkitSource.init(function onReady()
onResize()
);
// handle resize
window.addEventListener('resize', function()
onResize()
);
function onResize()
arToolkitSource.onResize()
arToolkitSource.copySizeTo(renderer.domElement)
if (arToolkitContext.arController !== null)
arToolkitSource.copySizeTo(arToolkitContext.arController.canvas)
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext(
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'data/camera_para.dat',
detectionMode: 'mono',
)
// initialize it
arToolkitContext.init(function onCompleted()
// copy projection matrix to camera
camera.projectionMatrix.copy(arToolkitContext.getProjectionMatrix());
)
// update artoolkit on every frame
onRenderFcts.push(function()
if (arToolkitSource.ready === false) return
arToolkitContext.update(arToolkitSource.domElement)
)
var markerRoot = new THREE.Group;
scene.add(markerRoot);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/ghall-marker.patt',
);
var markerRoot2 = new THREE.Group;
scene.add(markerRoot2);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot2,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/axe.patt',
);
var markerRoot3 = new THREE.Group;
scene.add(markerRoot3);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot3,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/tree.patt', );
var markerRoot4 = new THREE.Group;
scene.add(markerRoot4);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot4,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/sword.patt', );
var markerRoot5 = new THREE.Group;
scene.add(markerRoot5);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot5,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/planks.patt', );
var markerRoot6 = new THREE.Group;
scene.add(markerRoot6);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot6,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/minerals.patt', );
markerRoot.add(model1);
markerRoot2.add(axe);
markerRoot3.add(tree);
markerRoot4.add(sword);
markerRoot5.add(planks);
markerRoot6.add(minerals);
// render the scene
onRenderFcts.push(function()
renderer.render(scene, camera);
)
// run the rendering loop
var lastTimeMsec = null
requestAnimationFrame(function animate(nowMsec) );
</script>
I don't think each model needs to make a call to the init function, instead I think they should all be loaded and then there is only one init() which adds them all to the scene and renders them all. This would hopefully improve performance as well. I'm just not sure how to go about this?
You can see the issue I'm having if you visit https://arevisit.madamot.com
Or you can see what currently happens in this YouTube video
https://youtu.be/DjJdsBtfgvM
Many thanks,
Adam
javascript three.js collada artoolkit jsartoolkit
add a comment |
For this project I'm trying to create a AR scene where different markers will display different models.
I'm able to load and add a .DAE model using the Collada loader and as expected, when the user goes on the website the browser asks for the user's permission to use the camera.
This is achieved by using, as I said earlier, the ColladaLoader, adding the model to a variable called model1, scaling it and then calling the init function.
This init function creates a renderer, creates a scene and adds a camera etc, handles browser resize and adds the model markers.
Since adding the one model worked I thought to add more I could just copy and paste this colladaloader and point it to a different model and set a new marker for it. This fortunately works however when I visit the website on mobile it is incredibly sluggish and asks for my permission to use the camera 7/8 times (as many times as I have loaded models). This is due to, I think, after each model is loaded they all make a call to the init function. So it creates and adds as many scenes, cameras, renders etc as there are models.
Inspecting the page you can see there is a new canvas element for each model when there should be just one.
<script type="text/javascript">
var model1, axe, tree, sword, planks, minerals;
var loader = new THREE.ColladaLoader();
loader.load('greathallnow.DAE', function(collada)
model1 = collada.scene;
model1.scale.x = model1.scale.y = model1.scale.z = 0.5;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('axeyes.dae', function(collada)
axe = collada.scene;
axe.scale.x = axe.scale.y = axe.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('tree.dae', function(collada)
tree = collada.scene;
tree.scale.x = tree.scale.y = tree.scale.z = 0.01;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('swordplz.dae', function(collada)
sword = collada.scene;
sword.scale.x = sword.scale.y = sword.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('planks.dae', function(collada)
planks = collada.scene;
planks.scale.x = planks.scale.y = planks.scale.z = 0.05;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('stoneblockplural.dae', function(collada)
minerals = collada.scene;
minerals.scale.x = minerals.scale.y = minerals.scale.z = 0.25;
init();
);
function init()
// init renderer
var renderer = new THREE.WebGLRenderer(
antialias: true,
alpha: true
);
renderer.setClearColor(new THREE.Color('lightgrey'), 0)
renderer.setSize(640, 480);
renderer.domElement.style.position = 'absolute'
renderer.domElement.style.top = '0px'
renderer.domElement.style.left = '0px'
document.body.appendChild(renderer.domElement);
// array of functions for the rendering loop
var onRenderFcts = [];
// init scene and camera
var scene = new THREE.Scene();
// Create a camera
var camera = new THREE.Camera();
scene.add(camera);
var light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1);
scene.add(light);
var arToolkitSource = new THREEx.ArToolkitSource(
sourceType: 'webcam'
);
arToolkitSource.init(function onReady()
onResize()
);
// handle resize
window.addEventListener('resize', function()
onResize()
);
function onResize()
arToolkitSource.onResize()
arToolkitSource.copySizeTo(renderer.domElement)
if (arToolkitContext.arController !== null)
arToolkitSource.copySizeTo(arToolkitContext.arController.canvas)
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext(
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'data/camera_para.dat',
detectionMode: 'mono',
)
// initialize it
arToolkitContext.init(function onCompleted()
// copy projection matrix to camera
camera.projectionMatrix.copy(arToolkitContext.getProjectionMatrix());
)
// update artoolkit on every frame
onRenderFcts.push(function()
if (arToolkitSource.ready === false) return
arToolkitContext.update(arToolkitSource.domElement)
)
var markerRoot = new THREE.Group;
scene.add(markerRoot);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/ghall-marker.patt',
);
var markerRoot2 = new THREE.Group;
scene.add(markerRoot2);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot2,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/axe.patt',
);
var markerRoot3 = new THREE.Group;
scene.add(markerRoot3);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot3,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/tree.patt', );
var markerRoot4 = new THREE.Group;
scene.add(markerRoot4);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot4,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/sword.patt', );
var markerRoot5 = new THREE.Group;
scene.add(markerRoot5);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot5,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/planks.patt', );
var markerRoot6 = new THREE.Group;
scene.add(markerRoot6);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot6,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/minerals.patt', );
markerRoot.add(model1);
markerRoot2.add(axe);
markerRoot3.add(tree);
markerRoot4.add(sword);
markerRoot5.add(planks);
markerRoot6.add(minerals);
// render the scene
onRenderFcts.push(function()
renderer.render(scene, camera);
)
// run the rendering loop
var lastTimeMsec = null
requestAnimationFrame(function animate(nowMsec) );
</script>
I don't think each model needs to make a call to the init function, instead I think they should all be loaded and then there is only one init() which adds them all to the scene and renders them all. This would hopefully improve performance as well. I'm just not sure how to go about this?
You can see the issue I'm having if you visit https://arevisit.madamot.com
Or you can see what currently happens in this YouTube video
https://youtu.be/DjJdsBtfgvM
Many thanks,
Adam
javascript three.js collada artoolkit jsartoolkit
For this project I'm trying to create a AR scene where different markers will display different models.
I'm able to load and add a .DAE model using the Collada loader and as expected, when the user goes on the website the browser asks for the user's permission to use the camera.
This is achieved by using, as I said earlier, the ColladaLoader, adding the model to a variable called model1, scaling it and then calling the init function.
This init function creates a renderer, creates a scene and adds a camera etc, handles browser resize and adds the model markers.
Since adding the one model worked I thought to add more I could just copy and paste this colladaloader and point it to a different model and set a new marker for it. This fortunately works however when I visit the website on mobile it is incredibly sluggish and asks for my permission to use the camera 7/8 times (as many times as I have loaded models). This is due to, I think, after each model is loaded they all make a call to the init function. So it creates and adds as many scenes, cameras, renders etc as there are models.
Inspecting the page you can see there is a new canvas element for each model when there should be just one.
<script type="text/javascript">
var model1, axe, tree, sword, planks, minerals;
var loader = new THREE.ColladaLoader();
loader.load('greathallnow.DAE', function(collada)
model1 = collada.scene;
model1.scale.x = model1.scale.y = model1.scale.z = 0.5;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('axeyes.dae', function(collada)
axe = collada.scene;
axe.scale.x = axe.scale.y = axe.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('tree.dae', function(collada)
tree = collada.scene;
tree.scale.x = tree.scale.y = tree.scale.z = 0.01;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('swordplz.dae', function(collada)
sword = collada.scene;
sword.scale.x = sword.scale.y = sword.scale.z = 0.3;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('planks.dae', function(collada)
planks = collada.scene;
planks.scale.x = planks.scale.y = planks.scale.z = 0.05;
init();
);
var loader = new THREE.ColladaLoader();
loader.load('stoneblockplural.dae', function(collada)
minerals = collada.scene;
minerals.scale.x = minerals.scale.y = minerals.scale.z = 0.25;
init();
);
function init()
// init renderer
var renderer = new THREE.WebGLRenderer(
antialias: true,
alpha: true
);
renderer.setClearColor(new THREE.Color('lightgrey'), 0)
renderer.setSize(640, 480);
renderer.domElement.style.position = 'absolute'
renderer.domElement.style.top = '0px'
renderer.domElement.style.left = '0px'
document.body.appendChild(renderer.domElement);
// array of functions for the rendering loop
var onRenderFcts = [];
// init scene and camera
var scene = new THREE.Scene();
// Create a camera
var camera = new THREE.Camera();
scene.add(camera);
var light = new THREE.HemisphereLight(0xffffbb, 0x080820, 1);
scene.add(light);
var arToolkitSource = new THREEx.ArToolkitSource(
sourceType: 'webcam'
);
arToolkitSource.init(function onReady()
onResize()
);
// handle resize
window.addEventListener('resize', function()
onResize()
);
function onResize()
arToolkitSource.onResize()
arToolkitSource.copySizeTo(renderer.domElement)
if (arToolkitContext.arController !== null)
arToolkitSource.copySizeTo(arToolkitContext.arController.canvas)
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext(
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'data/camera_para.dat',
detectionMode: 'mono',
)
// initialize it
arToolkitContext.init(function onCompleted()
// copy projection matrix to camera
camera.projectionMatrix.copy(arToolkitContext.getProjectionMatrix());
)
// update artoolkit on every frame
onRenderFcts.push(function()
if (arToolkitSource.ready === false) return
arToolkitContext.update(arToolkitSource.domElement)
)
var markerRoot = new THREE.Group;
scene.add(markerRoot);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/ghall-marker.patt',
);
var markerRoot2 = new THREE.Group;
scene.add(markerRoot2);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot2,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/axe.patt',
);
var markerRoot3 = new THREE.Group;
scene.add(markerRoot3);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot3,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/tree.patt', );
var markerRoot4 = new THREE.Group;
scene.add(markerRoot4);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot4,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/sword.patt', );
var markerRoot5 = new THREE.Group;
scene.add(markerRoot5);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot5,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/planks.patt', );
var markerRoot6 = new THREE.Group;
scene.add(markerRoot6);
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot6,
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + 'data/minerals.patt', );
markerRoot.add(model1);
markerRoot2.add(axe);
markerRoot3.add(tree);
markerRoot4.add(sword);
markerRoot5.add(planks);
markerRoot6.add(minerals);
// render the scene
onRenderFcts.push(function()
renderer.render(scene, camera);
)
// run the rendering loop
var lastTimeMsec = null
requestAnimationFrame(function animate(nowMsec) );
</script>
I don't think each model needs to make a call to the init function, instead I think they should all be loaded and then there is only one init() which adds them all to the scene and renders them all. This would hopefully improve performance as well. I'm just not sure how to go about this?
You can see the issue I'm having if you visit https://arevisit.madamot.com
Or you can see what currently happens in this YouTube video
https://youtu.be/DjJdsBtfgvM
Many thanks,
Adam
javascript three.js collada artoolkit jsartoolkit
javascript three.js collada artoolkit jsartoolkit
asked Mar 27 at 20:22
MadamotMadamot
384 bronze badges
384 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385824%2fhow-do-i-load-and-add-multiple-models-to-a-ar-threex-artoolkit-scene%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385824%2fhow-do-i-load-and-add-multiple-models-to-a-ar-threex-artoolkit-scene%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown