Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArMarkerControls id output NaN instead of a number #5

Open
kalwalt opened this issue Jan 25, 2023 · 0 comments
Open

ArMarkerControls id output NaN instead of a number #5

kalwalt opened this issue Jan 25, 2023 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@kalwalt
Copy link
Member

kalwalt commented Jan 25, 2023

Note: ArMarkerControls is a dervied class from ArBaseControls
This happens because i implemented the code in this way

export class ArBaseControls extends EventDispatcher implements IArBaseControls {
static id: number;
private _id;
protected object3d: Object3D;
/**
* THe ArBaseControls constructor, you need to pass a Theee.js Object3d to it.
* @param object3d the Threejs Object3D to pass.
*/
constructor(object3d: Object3D) {
super()
this._id = ArBaseControls.id++;

original AR.js code here:

const ArBaseControls = function (object3d) {
  this.id = ArBaseControls.id++;


  this.object3d = object3d;
  this.object3d.matrixAutoUpdate = false;
  this.object3d.visible = false;


  // Events to honor
  // this.dispatchEvent({ type: 'becameVisible' })
  // this.dispatchEvent({ type: 'markerVisible' })	// replace markerFound
  // this.dispatchEvent({ type: 'becameUnVisible' })
};

ArBaseControls.id = 0;

https://github.com/AR-js-org/AR.js/blob/be7c9083df5a651c2ab978ddd7c1a33409c4d40b/three.js/src/threex/threex-arbasecontrols.js#L3-L16
I think this is a bad idea. The _id (should be re-named id) should simply be incremented and not added by the static id property. I will fix this.

@kalwalt kalwalt added bug Something isn't working enhancement New feature or request labels Jan 25, 2023
@kalwalt kalwalt self-assigned this Jan 25, 2023
kalwalt added a commit that referenced this issue Jan 25, 2023
- this need to be tested adding more than one marker.
kalwalt added a commit that referenced this issue Jan 26, 2023
- this need to be tested adding more than one marker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant