playcanvas-stable.dbg.js:42991 pc.Vec4#data is not public API and should not be used.
I am testing this script,So why it become like this?
.data
is internal API and not supposed to be used in game/app code hence the warning.
I have a floor and I need to transfrom its diffuseMap by Code,So what should I do?
I need your help
This sounds daft but I would have a Float32Array variable in the class scope and copy vec4.x/y/z/w into it and pass that to the mesh instance
:喜悦:What shoul I do next?
It looks like you are trying to scroll the diffuse map on a specific mesh instance. Are you not able to do this on the material instead of the mesh instance?
var Scroll = pc.createScript('scroll');
// initialize code called once per entity
Scroll.prototype.initialize = function() {};
// update code called every frame
Scroll.prototype.update = function(dt) {
var material = this.entity.model.material;
var v = (Date.now() % 1000) / 1000; // 1 scroll per second
material.diffuseMapOffset.set(0, v);
material.update();
};
If you do have a requirement to do this on the mesh instance itself, you would do:
Floor.prototype.initialize = function() {
this.vec = new Float32Array(4);
};
Floor.prototype.update = function(dt) {
if (!this.speed) return;
this.vec[3] -= (this.speed * 1000 / 60 / 60) * dt;
if (this.vec[3] < 0) this.vec[3] += 1;
this.entity.model.meshInstances[0].setParameter('texture_diffuseMapTransform', this.vec);
};
Because setParameter needs a Float32Array
type when setting vector uniform values, not a pc.Vec2/3/4
type.
Can I request that, in future, you paste actual code and not a screenshot? Otherwise, I have to retype all your code by hand.
Appreciate for your help:)will