From 8101d4c77c6babf125dbe8d4a40f1b2a72a70376 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Fri, 19 Apr 2013 11:15:29 +0200 Subject: Reset controls when setting the pose --- apps/samples/vrml/annotations.js | 6 ++---- apps/samples/vrml/viewer.js | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/apps/samples/vrml/annotations.js b/apps/samples/vrml/annotations.js index ca9bf0a..b91ccfa 100644 --- a/apps/samples/vrml/annotations.js +++ b/apps/samples/vrml/annotations.js @@ -34,13 +34,11 @@ function Annotations(element, params) { var pose = dojo.clone(self.vrmlViewer.pose); var imageURL = self.vrmlViewer.imageURL; var annoLink = document.createElement("a"); - annoLink.setAttribute("href", "#"); var annoText = document.createTextNode(text + "\n"); + annoLink.setAttribute("href", "#"); annoLink.appendChild(annoText); annoLink.onclick = function() { - self.vrmlViewer.pose = pose; - self.vrmlViewer.imageURL = imageURL; - self.vrmlViewer.updateScene(); + self.vrmlViewer.setPose(imageURL, pose); } this.messagesElem.appendChild(annoLink); } diff --git a/apps/samples/vrml/viewer.js b/apps/samples/vrml/viewer.js index 75b7b90..dedeb44 100644 --- a/apps/samples/vrml/viewer.js +++ b/apps/samples/vrml/viewer.js @@ -7,7 +7,8 @@ function VRMLViewer(element, params) { if (!VRMLViewer.instances) VRMLViewer.instances = 0; var instanceId = VRMLViewer.instances++; - + var batchChanges = false; + // public attributes this.pose = {}; this.pose.pitch = 0; @@ -325,7 +326,7 @@ function VRMLViewer(element, params) { // privileged public methods this.updateScene = function() { - if (self.imageURL) { + if (self.imageURL && !self.batchChanges) { self.imgElem.src = self.imageURL + '?width=' + self.pose.width + '&height=' + self.pose.height + @@ -341,8 +342,8 @@ function VRMLViewer(element, params) { } this.refreshServer = function(server) { - serverURL = server; - self.localStorage.put("vrmlServer", serverURL, null); + self.serverURL = server; + self.localStorage.put("vrmlServer", self.serverURL, null); self.xhr.get({ // The URL to request url: server, @@ -365,6 +366,23 @@ function VRMLViewer(element, params) { }); } + this.setPose = function(imageURL, pose) { + self.imageURL = imageURL; + self.pose = pose; + + self.batchChanges = true; +// self.fileList.set('item', imageURL); + self.xSpinner.set('value',pose.x); + self.ySpinner.set('value',pose.y); + self.zSpinner.set('value',pose.z); + self.pitchSlide.attr('value',pose.pitch); + self.rollSlide.attr('value',pose.roll); + self.yawSlide.attr('value',pose.yaw); + self.zoomSlide.attr('value',pose.zoom); + self.batchChanges = false; + updateScene(); + } + /* view = "normal"; // if (params.view == "maximized") { -- cgit v0.12