Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ShaderMaterial and Stats components not working #62

Closed
AlbanCrepel opened this issue May 15, 2021 · 3 comments
Closed

ShaderMaterial and Stats components not working #62

AlbanCrepel opened this issue May 15, 2021 · 3 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@AlbanCrepel
Copy link

I tried to use ShaderMaterial but I am getting this error :

TypeError: Cannot set property 'texture1' of undefined at Proxy.initTexture (Texture.ts:48) at Proxy.refreshTexture (Texture.ts:54) at Proxy.created (Texture.ts:28)

Here is my template :

<Plane :width="ratio"
       :height="1"
       :widthSegments="50"
       :heightSegments="50">
	<ShaderMaterial :props="{vertexShader, uniforms, fragmentShader}">
		<Texture src="/@assets/images/4.jpg"
		         uniform="texture1"
		         ref="texture"
		         :onLoad="onTextureLoaded" />
	</ShaderMaterial>
</Plane>

It works well with a BasicMaterial, like so :

<Plane :width="ratio"
       :height="1"
       :widthSegments="50"
       :heightSegments="50">
	<BasicMaterial>
		<Texture src="/@assets/images/4.jpg" />
	</BasicMaterial>
</Plane>

I also tried with the default vertexShader and fragmentShader but it didn't work either. I am thinking that this might be related to this commit.

Also, the Stats component didn't work, getting this error : Failed to resolve import "stats.js" from "node_modules/troisjs/src/components/misc/Stats.js". Does the file exist?. I copy pasted the import from the doc : import Stats from 'troisjs/src/components/misc/Stats' (using vitejs for development).

@klevron
Copy link
Member

klevron commented May 15, 2021

You are right about the texture, I made a fix and will release a version soon, sorry for the bug.

About stats.js you should add the package : yarn add -D stats.js

PS: hope to come to fly around Annecy one day :)

@klevron klevron added bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers labels May 15, 2021
@AlbanCrepel
Copy link
Author

Oh sorry about the stats, that was quite obvious 😅

Ok thanks for having a look, I really appreciate the reactivity.

(Well, Biarritz is quite nice too 😉 )

@klevron klevron closed this as completed May 17, 2021
@klevron
Copy link
Member

klevron commented May 17, 2021

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants