AltspaceVR / AltspaceSDK

Software Development Kit for AltspaceVR
https://developer.altvr.com/
MIT License
161 stars 73 forks source link

HoverScale Improvements #204

Open NGenesis opened 7 years ago

NGenesis commented 7 years ago
stevenvergenz commented 7 years ago

I'm confused what functionality this PR actually adds. Wouldn't it make more sense to put the behavior on an empty node that's parent to the trigger and the receiver?

NGenesis commented 7 years ago

The desired behavior using the eventListener property is to have one object trigger the scaling effect of another object when the trigger object is hovered over, without affecting the object that triggered the effect.

For example:

var boxTrigger = new THREE.Mesh(new THREE.BoxBufferGeometry(1, 1, 1), new THREE.MeshBasicMaterial({ color: 'blue' }));
var boxNeutral = new THREE.Mesh(new THREE.BoxBufferGeometry(1, 1, 1), new THREE.MeshBasicMaterial({ color: 'green' }));
var boxTarget = new THREE.Mesh(new THREE.BoxBufferGeometry(1, 1, 1), new THREE.MeshBasicMaterial({ color: 'red' }));

var boxes = new THREE.Group();
boxes.add(boxTrigger, boxNeutral, boxTarget);

The desired behavior using the eventListener property in this case is to have boxTarget's scale be affected when only boxTrigger is hovered over, without affecting the scale of boxTrigger or boxNeutral.

// Hovering over boxTarget will affect the scale of boxTarget
// Hovering over boxNeutral or boxTrigger will not affect the scale of boxTarget
boxTarget.addBehavior(new altspaceutil.behaviors.HoverScale({ scale: 1.15, duration: 125 }));

Does not satisfy the desired behavior.

// Hovering over boxTrigger, boxNeutral or boxTarget will affect the scale of boxTrigger, boxNeutral and boxTarget
boxes.addBehavior(new altspaceutil.behaviors.HoverScale({ scale: 1.15, duration: 125 }));

Also does not satisfy the desired behavior.

// Hovering over boxTrigger will affect the scale of boxTarget
// Hovering over boxNeutral or boxTarget will not affect the scale of boxTarget
boxTarget.addBehavior(new altspaceutil.behaviors.HoverScale({ scale: 1.15, duration: 125, eventListener: boxTrigger }));

Allowing the object that will trigger the scaling effect to be explicitly specified satisfies the desired behavior.

stevenvergenz commented 7 years ago

Could you add a test case to examples/tests?

NGenesis commented 7 years ago

Test case based on the above example can be found at examples/tests/behaviors-hoverscale.html

NGenesis commented 7 years ago

Any updates/questions/comments about this pull request?

stevenvergenz commented 7 years ago

Sorry for the delay. Finally got around to trying it out, it looks good! We'll merge it in with the next SDK push. Sound good?