Comments (3)
Responded here: https://discourse.threejs.org/t/troika-3d-text-library-for-sdf-text-rendering/15111/21?u=lojjic
If you run into specific issues with it, feel free to reopen this, with details.
from troika.
Responded here: https://discourse.threejs.org/t/troika-3d-text-library-for-sdf-text-rendering/15111/21?u=lojjic
If you run into specific issues with it, feel free to reopen this, with details.
I have applied the custom shader, but glsl error appears, I really don't know if I am doing it correctly, could you guide me?
textMesh.text = "Hello world!";
textMesh.font =
"https://rawcdn.githack.com/AlainBarrios/Fonts/c0615b21ea752212b7de8bca4cff49b85554393d/WILD WORLD.otf?raw=true";
textMesh.fontSize = 0.25;
textMesh.material = new THREE.ShaderMaterial({
uniforms: textMesh.material.uniforms,
vertexShader: vs,
fragmentShader: fs
});
textMesh.position.z = -1;
textMesh.anchorX = "center";
textMesh.anchorY = "top-baseline";
textMesh.color = 0x9966ff;
uniform float uTime;
uniform sampler2D uTexture;
uniform sampler2D diffuse;
varying vec2 vUv;
void main(){
vec4 text = texture2D(uTexture, vUv);
gl_FragColor = text;
}
from troika.
Thanks for the code. I'm still unsure of what exactly you're trying to accomplish, since you appear to be attempting to grab the previous material's uniforms for some reason? You shouldn't need to do that. If all you're trying to do is use your own ShaderMaterial, you can just use it like you would for any other mesh:
textMesh.material = new THREE.ShaderMaterial({
uniforms: {
// your uniforms here...
uTime: {value: 0},
uTexture: {value: myTexture},
//etc...
},
vertexShader: vs,
fragmentShader: fs
});
Then you can update your uniforms like normal
textMesh.material.uniforms.uTime = Date.now() - epoch;
Just be sure you do that by requesting textMesh.material
, not the original ShaderMaterial instance you created, as they'll be different instances. All of TextMesh's own uniforms will be seamlessly added behind the scenes so you should never have to worry about them.
Does that help?
from troika.
Related Issues (20)
- Discussion about a new feature---How can I control the width and height ratio (aspect ratio)? HOT 4
- Text.sync can't update the mesh smoothly when I excute sync method quickly HOT 3
- About fonts CDN HOT 3
- Can I call sync with async/await syntax? HOT 2
- Util function getCaretAtPoint can't get the uniform text caret vertical position for number/character and Chinese text. HOT 5
- Runtime error: 'webgl-sdf-generator' does not contain a default export (imported as 'createSDFGenerator'). HOT 3
- Emoji and Unicode support HOT 3
- Memory Issue with troika-three-text HOT 5
- troika-three-text: Indic shaping
- getCaretAtPoint(...) taking surrogate pairs into consideration HOT 2
- Support ligature caret positioning provided in font
- anchorY="bottom-baseline" not working since v0.48.0 HOT 2
- Glitches when used with Montserrat HOT 2
- Cloning a synced text still requires sync();
- [ Angular 17 ] - TS2307: Cannot find module 'troika-three-text' or its corresponding type declaratio HOT 1
- troika-three-text uncaught exception HOT 8
- Apply GLSL shader to only some letters
- Fix netlify links in documentation
- Cannot set property customDepthMaterial of #<InstancedUniformsMesh> which has only a getter
- LinearEncoding was not found in 'three'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from troika.