Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How change the bevel size of 3d text in x3dom?

How change the bevel size of 3d text in x3dom? Now i have code like this

<x3d width="392px" height="392px">
<scene>
  <viewpoint position='0 0 11'></viewpoint>
  <background skyColor='0.5 0.5 0.5'></background>
  <shape>
    <appearance>
      <material ambientIntensity='0.0933' diffuseColor='0.32 0.54 0.26' shininess='0.51' specularColor='0.46 0.46 0.46'></material>
    </appearance>
    <text string='Mono bolditalic 32px' solid='false'>
        <fontstyle family="TYPEWRITER" style="BOLDITALIC" size="0.8"></fontstyle>
    </text>
  </shape>
  <transform translation='0 0 -2'>
    <shape>
        <appearance> 
            <material diffuseColor="1 0 0" specularColor="0.5 0.5 0.5"></material>
        </appearance>
        <box></box>
    </shape>
  </transform>
</scene>
</x3d>

Is there any sample code available for this?

like image 218
crynaldo madrid Avatar asked Nov 29 '12 10:11

crynaldo madrid


1 Answers

It looks like there aren't any outright examples of beveling text with X3Dom alone. three.js seems to be the only webgl solution, I see, where you can easily change the bevel of 3D text. You seem to have found this based on your latest questions.

Here are some other good resources/examples for three.js.

  • Good intro. slides: http://fhtr.org/BasicsOfThreeJS
  • http://stemkoski.github.com/Three.js/
  • http://mrdoob.github.com/three.js/examples/canvas_geometry_text.html
  • https://github.com/mrdoob/three.js/tree/master/examples

Also, here are some JSFiddle examples. These will be much easier to read/experiement with.

  • http://jsfiddle.net/theo/VsWb9/
  • http://jsfiddle.net/GKCx6/139/

I was having issues getting a JSFiddle setup. A fellow programmer was having a similar issue but with his help I setup a useful example. This will allow you a chance to experiment with the bevel capability.

Bevel Example: http://jsfiddle.net/VsWb9/674/

JavaScript

// This is where stuff in our game will happen:
var scene = new THREE.Scene();

// This is what sees the stuff:
var aspect_ratio = window.innerWidth / window.innerHeight;
var camera = new THREE.PerspectiveCamera(45, aspect_ratio, 1, 100000);
camera.position.z = 800;
camera.position.x = 350;

scene.add(camera);

// This will draw what the camera sees onto the screen:
var renderer = new THREE.WebGLRenderer();

// var renderer = new THREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// ******** START CODING ON THE NEXT LINE ********
var shape = new THREE.TextGeometry("Game Over", 
                                   {font: 'helvetiker',
                                    bevelThickness: '3',
                                    bevelSize: '3',
                                    bevelSegments: '4',
                                    bevelEnabled: 'true'});
var wrapper = new THREE.MeshNormalMaterial({color: 0x00ff00});
var words = new THREE.Mesh(shape, wrapper);
scene.add(words);

// Now, show what the camera sees on the screen:
renderer.render(scene, camera);

Additional JS

<script src="http://gamingJS.com/Three.js"></script>
<script src="http://gamingJS.com/ChromeFixes.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/fonts/helvetiker_regular.typeface.js"></script>
like image 80
JSuar Avatar answered Nov 16 '22 20:11

JSuar