EventDispatcher (r58)

编程入门 行业动态 更新时间:2024-10-24 22:25:20
本文介绍了EventDispatcher (r58)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

关于 r58 中的 EventDispatcer 发生了一些变化,我无法向对象添加更多自定义事件.根据 将自定义事件添加到 Object3D 我曾经拥有:

Something changed in regards to the EventDispatcer in r58 and I cannot add any more custom events to Objects. As per Add custom event to Object3D I used to have:

var spinner_obj = new THREE.Object3D();
THREE.EventDispatcher.call( spinner_obj );
spinner_obj.addEventListener('start', function(event) {alert("GOT THE EVENT");});
spinner_obj.dispatchEvent({type:'start'});

但这在 r58 中停止工作并显示错误消息:

but this stopped working in r58 with the error message:

Object [object Object] has no method 'addEventListener' 

推荐答案

现在它使用函数的单个实例,而不是在每个对象中复制它.

Now it's using a single instance of the functions instead of duplicating it in every object.

这是我目前找到的最好的方法:https://github/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js#L11-L14

This is the best approach I've found so far: https://github/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js#L11-L14

我想我会让 Object3D 扩展 EventDispatcher 原型...

I think I'll make Object3D extend EventDispatcher prototype though...

这篇关于EventDispatcher (r58)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 15:40:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1396278.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:EventDispatcher

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!