Skip to content

Commit 4502c8f

Browse files
author
Farhad Ghayour
committed
Feat: WebGL events functionality for various discrete events
1 parent 0caab09 commit 4502c8f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

webgl-renderables/Mesh.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ Mesh.prototype.onOpacityChange = function onOpacityChange (opacity) {
596596
*
597597
* @return {undefined} undefined
598598
*/
599-
Mesh.prototype.onAddUIEvent = function onAddUIEvent (UIEvent) {
599+
Mesh.prototype.onAddUIEvent = function onAddUIEvent(UIEvent) {
600600
if (this._UIEvents.indexOf(UIEvent) === -1) {
601601
this._subscribe(UIEvent);
602602
this._UIEvents.push(UIEvent);

webgl-renderers/WebGLRenderer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,15 @@ function WebGLRenderer(canvas, compositor, eventDiv) {
139139
this.bufferRegistry.allocate(cutout.spec.id, 'indices', cutout.spec.bufferValues[3], 1);
140140

141141
/**
142-
* WebGL Picking by caputing hit testing ('clicks') using the
142+
* WebGL Picking by caputing events (e.g. 'click') using the
143143
* main famous HTML element for capturing events.
144144
*/
145+
var ev;
145146
this.listeners = {};
146147
this.meshIds = 0;
147-
this.eventsMap = ['click'];
148-
var ev;
148+
this.eventsMap = ['click', 'dblclick', 'mousewheel', 'touchstart',
149+
'keyup', 'keydown', 'mousedown', 'mouseup',
150+
'scroll', 'select', 'touchend', 'wheel'];
149151

150152
var len = this.eventsMap.length;
151153
for(var i = 0; i < len; i++) {
@@ -213,7 +215,7 @@ WebGLRenderer.prototype.checkEvent = function checkEvent(x, y, type) {
213215
var picked = this.listeners[type][meshId];
214216

215217
if (picked) {
216-
this.compositor.sendEvent(picked.path, 'click', {});
218+
this.compositor.sendEvent(picked.path, type, {});
217219
}
218220

219221
return picked;

0 commit comments

Comments
 (0)