qwertyz Posted July 31, 2019 Share Posted July 31, 2019 I've been trying to change the texture of a 3d model but every time I call diffuseTexture on the mesh that I need the texture to be applied to it does not work, I tried playing around in the babylon sandbox and I applied the texture there and it didn't work when I first added the texture, but there were an option which said "Render as main texture" and when I turned it ON it worked and the texture was applied in the sandbox, now how can I apply the same thing on my 3d model... // The code trying to change the texture this.scene.getMeshByID('637b73d9-6073-4081-9ca1-56be54919ba7').material.diffuseTexture = new Texture("assets/img/deri_01.jpg", this.scene) console.log(this.scene.getMeshByID('859bfb84-0db5-43e7-b73b-a742694f7b70').material) // In the console diffuseTexture: f animations: [] anisotropicFilteringLevel: 4 canRescale: (...) coordinatesIndex: 0 coordinatesMode: 0 delayLoadState: 0 gammaSpace: true getAlphaFromRGB: false hasAlpha: false invertZ: false is3D: false isBlocking: true isCube: false isRGBD: false isRenderTarget: false level: 1 lodGenerationOffset: (...) lodGenerationScale: (...) lodLevelInAlpha: false name: "assets/img/deri_01.jpg" noMipmap: false onDisposeObservable: t {_observers: Array(0), _eventState: e} onLoadObservable: t {_observers: Array(0), _eventState: e} samplingMode: (...) sphericalPolynomial: (...) textureFormat: (...) textureType: (...) uAng: 0 uOffset: 0 uRotationCenter: 0.5 uScale: 1 uid: (...) url: "assets/img/deri_01.jpg"<-----You can see the texture file here but it is not applied! vAng: 0 vOffset: 0 vRotationCenter: 0.5 vScale: 1 wAng: 0 wRotationCenter: 0.5 wrapR: 1 wrapU: 1 wrapV: 1 _buffer: null _cachedSize: r {width: 0, height: 0} _cachedTextureMatrix: g {_isIdentity: true, _isIdentityDirty: false, m: Float32Array(16), updateFlag: 8673} _cachedUAng: 0 _cachedUOffset: 0 _cachedUScale: 1 _cachedVAng: 0 _cachedVOffset: 0 _cachedVScale: 1 _cachedWAng: 0 _coordinatesMode: 0 _deleteBuffer: false _hasAlpha: false _invertY: true _isBlocking: true _lodTextureHigh: (...) _lodTextureLow: (...) _lodTextureMid: (...) _noMipmap: false _rowGenerationMatrix: g {_isIdentity: false, _isIdentityDirty: true, m: Float32Array(16), updateFlag: 8672} _samplingMode: 3 _scene: E {rootNodes: Array(30), cameras: Array(1), lights: Array(3), meshes: Array(316), skeletons: Array(0), …} _t0: d {x: 0, y: 0, z: 0} _t1: d {x: 1, y: 0, z: 0} _t2: d {x: 0, y: 1, z: 0} _texture: o {onLoadedObservable: t, previous: q, next: q, _initialSlot: 0, _designatedSlot: 1, …} _uid: null Quote Link to comment Share on other sites More sharing options...
Guest Posted September 26, 2019 Share Posted September 26, 2019 Please post your question on the new forum:https://forum.babylonjs.com/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.