# Overwrite new BABYLON.Vector3.X

**URL:** <https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528>\
**Category:** Questions\
**Created:** [February 21, 2019, 3:27pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528 "2019-02-21T15:27:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![weshuiz13](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/weshuiz13/32/16613_2.png) [@weshuiz13](https://forum.babylonjs.com/u/weshuiz13)\
**Post date:** [February 21, 2019, 3:27pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/1 "2019-02-21T15:27:38Z")

</div>

just a simple question sometimes i see new BABYLON.Vector3.whatever  
how would i overwrite that with new propeties?

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [February 21, 2019, 5:48pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/2 "2019-02-21T17:48:53Z")

</div>

Can you give a concrete example? I don’t understand your question.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [February 21, 2019, 6:09pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/3 "2019-02-21T18:09:49Z")

</div>

so you want to add a prototype to Vector3?

you can do

BABYLON.Vector3.prototype…  
or  
BABYLON.Vector3.ThingIwantToAdd = class{  
…  
}

for example you want a vector that is added to a constant or something:

BABYLON.Vector3.prototype.QuickMaths = function(v){  
return v.add(new BABYLON.Vector3(2,2,2));  
}

---

<div class="post-metadata">

**Author:** ![weshuiz13](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/weshuiz13/32/16613_2.png) [@weshuiz13](https://forum.babylonjs.com/u/weshuiz13)\
**Post date:** [February 22, 2019, 8:28am UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/4 "2019-02-22T08:28:45Z")

</div>

an example would be  
`points.push( new BABYLON.Vector3(i - 25, 5 * Math.sin(i / 2), i /5 * Math.cos(i / 2)) );`  
how would i modify this later?

---

<div class="post-metadata">

**Author:** ![timetocode](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/timetocode/32/111_2.png) [@timetocode](https://forum.babylonjs.com/u/timetocode)\
**Post date:** [February 22, 2019, 9:32am UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/5 "2019-02-22T09:32:10Z")

</div>

Is this what you’re asking?

```auto
const myVector = new BABYLON.Vector3(i - 25, 5 * Math.sin(i / 2), i /5 * Math.cos(i / 2)) 
points.push(myVector)

myVector.x += 5

```

---

<div class="post-metadata">

**Author:** ![weshuiz13](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/weshuiz13/32/16613_2.png) [@weshuiz13](https://forum.babylonjs.com/u/weshuiz13)\
**Post date:** [February 22, 2019, 2:05pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/6 "2019-02-22T14:05:09Z")

</div>

it gets pretty close but i rather overwrite the whole myVector  
a other sample would be this

`redball.material = red;` if i would like to have blue as the color  
i could make a second color call it blue and do `redball.material = blue;`  
but thats not my point i rather edit red to use a blue color if you know what i mean

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [February 22, 2019, 5:16pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/7 "2019-02-22T17:16:05Z")

</div>

points[id].x = ?

you can access the array that you are making later and then access the xyz parameters if you select one of your points.

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [February 22, 2019, 6:25pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/8 "2019-02-22T18:25:24Z")

</div>

> [@weshuiz13](#):
>
> `redball.material = red;` if i would like to have blue as the color  
> i could make a second color call it blue and do `redball.material = blue;`  
> but thats not my point i rather edit red to use a blue color if you know what i mean

> **[Babylon.js Playground](https://playground.babylonjs.com/#3NNQV5)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

or `mat.emissiveColor = ...`

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [February 22, 2019, 6:26pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/9 "2019-02-22T18:26:51Z")

</div>

points[i] = new vector3?

If you are pushing them into an array, you can access them and modify them all you want later if you know which one you are trying to access ID.

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [February 22, 2019, 6:38pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/10 "2019-02-22T18:38:49Z")

</div>

> [@timetocode](#):
>
> ```auto
> const myVector = new BABYLON.Vector3(i - 25, 5 * Math.sin(i / 2), i /5 * Math.cos(i / 2)) 
> points.push(myVector)
> 
> ```

Then

```auto
myVector.set(-1, 2, Math.PI / 4)

```

??? Getting closer?

---

<div class="post-metadata">

**Author:** ![weshuiz13](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/weshuiz13/32/16613_2.png) [@weshuiz13](https://forum.babylonjs.com/u/weshuiz13)\
**Post date:** [March 1, 2019, 1:13pm UTC](https://forum.babylonjs.com/t/overwrite-new-babylon-vector3-x/1528/11 "2019-03-01T13:13:46Z")

</div>

my apoligize for inacitvity ☹
