question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isVector3 is present when serializing Vector3

See original GitHub issue

Describe the bug

A clear and concise description of what the bug is. Before submitting, please remove unnecessary sections.

since r141, when serializing Vector3 class using JSON.stringify, isVector3 is present

To Reproduce

Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. See error

Code

// r141
console.log(new THREE.Vector3())
// output:
// {isVector3: true, x: 0, y: 0, z: 0}

// r140
console.log(new THREE.Vector3())
// output:
// {x: 0, y: 0, z: 0}

Live example

*141

*140 Expected behavior

Should not contains isVector3 ( also, I don’t think it is a good idea to have a boolean inside an heavily use class memory wise )

Screenshots

image

Platform:

  • Device: [Desktop, Mobile]
  • OS: [Windows, MacOS, Linux, Android, iOS]
  • Browser: [Chrome, Firefox, Safari, Edge]
  • Three.js version: [dev, r???]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:39 (28 by maintainers)

github_iconTop GitHub Comments

5reactions
donmccurdycommented, Jun 7, 2022

I’m worried that this thread seems pretty far down a very niche path… THREE.Vector3 does not need to be optimized around storing millions of Vector3 instances in memory — that’s a terrible choice for performance regardless of this particular boolean property. This is the reason why three.js (and GPU APIs) have moved toward typed-array-based APIs like BufferAttribute instead. If you need to iterate over many vertices, a small number of vectors should be pooled and initialized, when needed, from compact binary views.

Let’s keep .is properties please, they’re fine. 🙏

2reactions
olivierchatrycommented, Jun 9, 2022

Well, never mind, we did something really stupid ( I removed the simplifyRadialDist from the typedarray buffer test … ). I guess I’m not blown away anymore !

For science:

With simplifyRadialDist on both test ( vec3, typedarray ):

❯ node bench.js
arrayWrite 2600.320638999983 milliseconds.
vec3Write 3766.281397999992 milliseconds.
three.js/src/math on  dev [?⇣] with  took 6s
❯ node bench.js
arrayWrite 2905.3484539999918 milliseconds.
vec3Write 4216.024967000005 milliseconds.
three.js/src/math on  dev [?⇣] with  took 7s

Without simplifyRadialDist on both test ( vec3, typedarray ):

❯ node bench.js
arrayWrite 4425.489473998547 milliseconds.
vec3Write 5163.734323002398 milliseconds.
three.js/src/math on  dev [?⇣] with  took 9s
❯ node bench.js
arrayWrite 4212.7496079951525 milliseconds.
vec3Write 5430.644314996898 milliseconds.
three.js/src/math on  dev [?⇣] with  took 9s

We were comparing vec3 with simplifyRadialDist against typedarray without. Not really a fair fight. At least I now have peace of mind on that because I was really disturb when we tried.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vector3 is not marked serializable - Unity Forum
I do. But, when there is Vector3 as member, it will say Vector3 is not marked serializable.
Read more >
c# - How to serialize a Vector3 using binary serializer?
Seems Vector3 is not serializable (as well as Quaternion). Wrap it within your own V3 class/struct or serialize each float individually.
Read more >
Vector3 – three.js docs
Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used...
Read more >
three.js - Apple Open Source
setFromEuler() now expects an Euler rotation rather than a Vector3 and order. ... Object.assign( Vector3.prototype, { isVector3: true, set: function ( x, y, ......
Read more >
Team:Munich/Hardware/threeJS - iGEM 2018
// We compute the minimum and maximum dot product values. If those values // are on the same side (back or front) of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found