Pick event routing broken across Instance-Symbol links
Reported by lindsay.kay (at xeolabs) | August 7th, 2010 @ 07:50 AM | in V0.7.7
When pick events are handled within multiply-instanced Symbols, where the event originates within the subnodes of the Instances, the Symbol can get confused about which Instance the event originated from.
On the render pass directly following the pick pass, the observer within the Symbol's subgraph has the picked event, which it actions on immediately. Trouble is, the event may be from another subsequently-rendered instance, not the one being currently rendered. For example, if the second teapot in the example below is clicked, the "teapot-controller" will queue a pick event, which it will process the first time it is instanced for the for the first teapot.
SceneJS.symbol({
sid: "teapot-controller" },
SceneJS.withConfigs({
listeners: {
"picked":{
fn : function(params) {
/*
* When "teapot" is picked, we'll push a new baseColor down
* into its "teapot-color" Material node
*/
// alert(this.getSID() + " handling 'picked' event from " + params.uri);
if (params.uri.match("^teapot") == "teapot") {
this.setConfigs({
"#teapot" : {
"#teapot-color": {
baseColor: {r: Math.random(), g:Math.random(), b: Math.random() }
}
}
});
this.setOnce(true);
}
}
}
}
}
)),
SceneJS.instance({ uri: "teapot-controller" },
SceneJS.node({ sid: "teapot" },
SceneJS.translate({ x: -7 },
SceneJS.material({
sid: "teapot-color",
baseColor: { r: 0.3, g: 0.3, b: 0.9 },
specularColor: { r: 0.9, g: 0.9, b: 0.9 },
specular: 0.9,
shine: 6.0
},
SceneJS.objects.teapot())))),
SceneJS.instance({ uri: "teapot-controller" },
SceneJS.node({ sid: "teapot" },
SceneJS.translate({ x: 0 },
SceneJS.material({
sid: "teapot-color",
baseColor: { r: 0.3, g: 0.3, b: 0.9 },
specularColor: { r: 0.9, g: 0.9, b: 0.9 },
specular: 0.9,
shine: 6.0
},
SceneJS.objects.teapot())))),
SceneJS.instance({ uri: "teapot-controller" },
SceneJS.node({ sid: "teapot" },
SceneJS.translate({ x: 7 },
SceneJS.material({
sid: "teapot-color",
baseColor: { r: 0.3, g: 0.3, b: 0.9 },
specularColor: { r: 0.9, g: 0.9, b: 0.9 },
specular: 0.9,
shine: 6.0
},
SceneJS.objects.teapot()))))
Comments and changes to this ticket
-
lindsay.kay (at xeolabs) August 11th, 2010 @ 03:26 AM
- State changed from new to resolved
- Tag set to events, picking
Fixed by using new event management for picking also: https://xeolabs.lighthouseapp.com/projects/50643-scenejs/tickets/14...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
SceneJS provides easy access to WebGL through a simple and declarative JavaScript API. The SceneJS API is functional, which enables its scene definitions to be really compact and expressive, while hooking into other JavaScript code just that little bit more smoothly.
People watching this ticket
Referenced by
- 143 Hash function for individual traversal states (node visits) This is to help the issue with correct event handling wit...