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

Vector3.prototype.isVector3 = true is being set inside the constructor of Vector3 class. #28079

Closed
0xF48 opened this issue Apr 7, 2024 · 2 comments

Comments

@0xF48
Copy link

0xF48 commented Apr 7, 2024

Description

why is being called every time a Vector3 object is created? shouldn't this be placed outside of the class?

Reproduction steps

Vector3 class prototype in https://github.com/mrdoob/three.js/blob/dev/src/math/Vector3.js#L8

Code

import * as MathUtils from './MathUtils.js';
import { Quaternion } from './Quaternion.js';

class Vector3 {

constructor( x = 0, y = 0, z = 0 ) {

	Vector3.prototype.isVector3 = true;

	this.x = x;
	this.y = y;
	this.z = z;

}

Live example

no example

Screenshots

No response

Version

r163

Device

No response

Browser

No response

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 7, 2024

This is related to tree-shaking. I suggest you study the related issues and PRs in this context. E.g. #24047, #24167, #24219.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 7, 2024

Please use the forum if you have more questions about this topic.

@Mugen87 Mugen87 added this to the r164 milestone Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants