浏览代码

WebXRController: Convert to ES6 class. (#21648)

Michael Herzog 4 年之前
父节点
当前提交
7cac6d494f
共有 1 个文件被更改,包括 18 次插入20 次删除
  1. 18 20
      src/renderers/webxr/WebXRController.js

+ 18 - 20
src/renderers/webxr/WebXRController.js

@@ -1,18 +1,16 @@
 import { Group } from '../../objects/Group.js';
 import { Group } from '../../objects/Group.js';
 
 
-function WebXRController() {
+class WebXRController {
 
 
-	this._targetRay = null;
-	this._grip = null;
-	this._hand = null;
+	constructor() {
 
 
-}
-
-Object.assign( WebXRController.prototype, {
+		this._targetRay = null;
+		this._grip = null;
+		this._hand = null;
 
 
-	constructor: WebXRController,
+	}
 
 
-	getHandSpace: function () {
+	getHandSpace() {
 
 
 		if ( this._hand === null ) {
 		if ( this._hand === null ) {
 
 
@@ -27,9 +25,9 @@ Object.assign( WebXRController.prototype, {
 
 
 		return this._hand;
 		return this._hand;
 
 
-	},
+	}
 
 
-	getTargetRaySpace: function () {
+	getTargetRaySpace() {
 
 
 		if ( this._targetRay === null ) {
 		if ( this._targetRay === null ) {
 
 
@@ -41,9 +39,9 @@ Object.assign( WebXRController.prototype, {
 
 
 		return this._targetRay;
 		return this._targetRay;
 
 
-	},
+	}
 
 
-	getGripSpace: function () {
+	getGripSpace() {
 
 
 		if ( this._grip === null ) {
 		if ( this._grip === null ) {
 
 
@@ -55,9 +53,9 @@ Object.assign( WebXRController.prototype, {
 
 
 		return this._grip;
 		return this._grip;
 
 
-	},
+	}
 
 
-	dispatchEvent: function ( event ) {
+	dispatchEvent( event ) {
 
 
 		if ( this._targetRay !== null ) {
 		if ( this._targetRay !== null ) {
 
 
@@ -79,9 +77,9 @@ Object.assign( WebXRController.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	disconnect: function ( inputSource ) {
+	disconnect( inputSource ) {
 
 
 		this.dispatchEvent( { type: 'disconnected', data: inputSource } );
 		this.dispatchEvent( { type: 'disconnected', data: inputSource } );
 
 
@@ -105,9 +103,9 @@ Object.assign( WebXRController.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	update: function ( inputSource, frame, referenceSpace ) {
+	update( inputSource, frame, referenceSpace ) {
 
 
 		let inputPose = null;
 		let inputPose = null;
 		let gripPose = null;
 		let gripPose = null;
@@ -238,7 +236,7 @@ Object.assign( WebXRController.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
 
 
 
 
 export { WebXRController };
 export { WebXRController };