Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions examples/xml3d/loadxml3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,22 @@ require([
var freecamera = null;
// var instructions = null;

// Start freecam app
// Start freecam app - the xml3d parser will position current active cam by <view> declaration
$.getScript("../../src/application/freecamera.js")
.done(function( script, textStatus ) {
freecamera = new FreeCameraApplication();
freecamera.createCamera();
var sceneParserPlugin = TundraSDK.plugin("SceneParserPlugin");
var xml3dParser = sceneParserPlugin.newXML3DParser(client.scene);
$(document).ready(function() {
xml3dParser.parseDocXml3D(document);
});
})
.fail(function(jqxhr, settings, exception) {
console.error("Failed to load FreeCamera application:", exception);
}
);
});

/*
// Connected to server
client.onConnected(null, function() {
// Setup initial camera position
if (freecamera && freecamera.cameraEntity)
freecamera.cameraEntity.placeable.setPosition(0, 8.50, 28.50);

instructions = $("<div/>", {
text : "Click on the top sphere to start the physics simulation",
css : {
Expand All @@ -103,10 +102,4 @@ require([
var dirLight = new THREE.DirectionalLight();
client.renderer.scene.add(dirLight);
// });

var sceneParserPlugin = TundraSDK.plugin("SceneParserPlugin");
var xml3dParser = sceneParserPlugin.newXML3DParser(client.scene);
$(document).ready(function() {
xml3dParser.parseDocXml3D(document);
});
});
34 changes: 20 additions & 14 deletions src/plugins/scene-parser/SceneParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,31 @@ var SceneParser = Class.$extend(
viewPosition = xview.getAttribute("position");
viewOrientation = xview.getAttribute("orientation");

var entity = this.scene.createLocalEntity(["Name", "Placeable", "Camera"]);
entity.name = viewId || "XML3D View";

// Camera
var actcam = TundraSDK.framework.renderer.activeCamera();
var cament;
if (!actcam) {
cament = this.scene.createLocalEntity(["Name", "Placeable", "Camera"]);
cament.name = viewId || "XML3D View";
this.log.debug(" Created", cament.camera.toString());
cament.camera.setActive();
this.log.debug(" Activated camera in", cament.toString());
} else {
cament = actcam.parentEntity;
this.log.debug(" Configuring pre-existing active camera", cament.camera.toString());
}
// Placeable
var px = entity.placeable.transform;
if (viewPosition)
var px = cament.placeable.transform;
if (viewPosition) {
wtSplitToXyz(viewPosition, px.pos);
if (viewOrientation)
}
if (viewOrientation) {
wtSplitAxisAngleToEulerXyz(viewOrientation, px.rot);
entity.placeable.transform = px; // trigger signal
}
cament.placeable.transform = px; // trigger signal

// Camera
/// @todo Read and set aspect ratio to camera from <view>
//entity.camera.aspectRatio = ??;

this.log.debug(" Created", entity.camera.toString());
entity.camera.setActive();
this.log.debug(" Activated camera in", entity.toString());

//cament.camera.aspectRatio = ??;
}
}
});
Expand Down