Hello everybody, I would like to ask some support and will be very happy for your suggestions, help and advices!
I want to create customizer for name puzzle for kids.
The logic next:
- client enter the name, script generates 3d text.
- client select color scheme, script should change color(material) of each letter according to script scenario.
- client select if he want additional engraving on the back of the plate.
- client can add pegs for the letters.
- client approve product and image is being generated send via api with all selected values to our shop.
I started to work on it and learned many tutorials here and on the forum, but however I hope there can be some things community can help to understand if this possible and how can I implement it.
step 1.
Based on text-mesh.js script generates text that entered to html input field and when ENTER pressed script regenerates 3d text in viewport (this is step 1.)
//this code takes value from html input, put it into TextMesh.text attribute and recreates 3d text
TextMesh.prototype.update = function(dt) {
if (pc.app.keyboard.isPressed(pc.KEY_ENTER)) {
this.text = document.getElementById("name").value;
this.createText();
}
};
step 2.
I can change color of the whole name, but unfortunately I donāt understand, how can I apply different materials randomly to child elements (each letter).
I tried to set it with those commands:
this.material="1"; //this one change whole TextMesh material, this is good
this.entity._children[0].material="2"; // this one apply attribute that undefined previously, but it don't change the material of the selected child element
question 1 How to apply different material each letter separately?
step 3.
I guess I need to create plate at first and make it size dynamically changing based on the width of the 3d text generated.
I hope to find in Documentation something like, Dimension or Length instead of Position (LocalScale):
this.entity.getPosition();
this.entity.getLocalScale();
question 2 How can I get the width(one axis length) of selected object?
Link to the editor project:
https://playcanvas.com/editor/project/1157431
Link to the Launch(result) project:
https://launch.playcanvas.com/1890395?debug=true
I will be very happy to have help, advices, suggestions and will update this post during development and probably will have more questions soonā¦