This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > February 2005 > VRML, Javascript et EAI





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author VRML, Javascript et EAI
Fenrir

2005-02-15, 11:21 pm

Topo Vrml 3D, javascriptTest Vrml, HTML et Javascript
Le navigateur affiche le plugin bs contact, tout sembke fonctionner le navigateur ne retourne aucune erreur visible
Les commandes sont redondantes entre HTML et Vrml, on peut faire tourner le cube depuis l'ancre html comme depuis le cone du document vrml

Dans un premier temps il faut créer une librairie de script pour pousser plus avant les tests.

Prenons l'exemple de l'ancre Box color
Elle utilise la fonction sendEvent(a,b,c), les parametres a, b et c sont detaillés ci après
Les autres ancres font la meme chose il utilise la fonction sendEvent Seul les parametres varient


Reprenosn la definition de la fonction sendEvent(...)
function sendEvent(node, field, value) {
document.CC3D.setNodeEventIn(node, field, value)
}

Dans le cas de notre ancre changement de couleur voici la syntaxe : sendEvent('BoxColor','set_diffuseColor','0.7 0.5 0.2')
ici les parametres a(node),b(field),c(value) de la fonction ont pour valeurs 'BoxColor','set_diffuseColor','0.7 0.5 0.2'

syntaxe node field value commentaire
sendEvent('BoxColor','set_diffuseColor','0.7 0.5 0.2') BoxColor set_diffuseColor 0.7 0.5 0.2 (codage rvb) Change la couleur d'un cube en marron
sendEvent('BoxSwitch','set_whichChoice','-1')" BoxSwitch set_whichChoice -1 masque le cube
sendEvent('BoxSwitch','set_whichChoice','-1')" BoxSwitch set_whichChoice 0 afficher le cube
sendEvent('RotationScript','clicked','12345678')" RotationScript clicked 12345678 fait tourner le cube

Dans la definition du document vrml je trouve a la ligne 41 cette ligne :
material DEF BoxColor Material { diffuseColor 1 0 0 } BoxColor correspond par defaut à la couleur rouge

set_diffuseColor permet de définir la couleur , ou trouver plus de documentation sur les noed, champ et valeurs accesibles en script? La fonction de rotation prend en argument un nombre tres grand; est ce correct ? Comment faire une rotation sur les 3 axes ? Merci par avance VRML,

les fichiers sont inclues dans le code source html du post tout en bas du document; page1.html contient sample.wrl (tiré d un site chinois)

,
,
Si quelqu'un peut m'aider a decortiquer le code vrml,notament les definitions EXTERNPROTO

Outlook me tronque le message ...D'ou le scribouilli ci dessous j'esepre que les sources seront accessibles, sinon je les mettrai en FTP sur mon site perso,




sample.wrl #VRML V2.0 utf8 EXTERNPROTO BlaxxunZone [ eventIn MFNode addEvents eventIn MFNode removeEvents exposedField MFNode events ][ "shared.wrl#BlaxxunZone", "http://www.blaxxun.com/vrml/protos/shared.wrl#BlaxxunZone" ] EXTERNPROTO SharedEvent [ exposedField SFString name # for accessing a special event eventIn SFColor colorFromServer eventOut SFColor colorToServer eventIn SFColor set_color eventOut SFColor color_changed eventIn SFRotation rotationFromServer eventOut SFRotation rotationToServer eventIn SFRotation set_rotation eventOut SFRotation rotation_changed eventOut SFString string_changed eventIn SFString stringFromServer ] [ "shared.wrl#SharedEvent", "http://www.blaxxun.com/vrml/protos/shared.wrl#SharedEvent" ] DEF SharedZone BlaxxunZone { events [ DEF SharedColor SharedEvent { name "newColor" } DEF SharedRotation SharedEvent { name "newRotation" } ] } DEF BoxSwitch Switch { whichChoice 0 choice [ DEF BoxRotation Transform { children [ Shape { # appearance Appearance { material DEF BoxColor Material { diffuseColor 1 0 0 } } geometry Box { } } ] } ] } # ´ËÇòÌåÓÃÀ´¸ü»»ÑÕÉ« Transform { translation -4 0 0 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Sphere {} },DEF ColorSensor TouchSensor {}, DEF ColorScript Script { eventIn SFTime clicked eventIn SFString changeColor eventOut SFColor color_changed eventOut SFColor color_changed_from_bot url "vrmlscript: function clicked (value, time) { color_changed = new SFColor(Math.random(),Math.random(),Math.random()); } function changeColor (value, time) { tempColor = new SFColor(1,0,0); temp = new SFString(value); pos1 = 7; for (i=0; i<3;i++){ temp2 = new SFString(temp.substring(pos1,pos1+1)); if (temp2 == '1') tempColor[i] = 1; pos2 = temp.indexOf(' ',pos1); pos1 = pos2+1; } color_changed_from_bot = tempColor; } " } ] } # cone Transform { translation 4 0 0 children [ Shape { appearance Appearance { material Material { diffuseColor 0 0 1 } } geometry Cone {} },DEF RotSensor TouchSensor {}, DEF RotationScript Script { field MFString newurl [ "OnEvent( par1, par2 )" ] # field MFString newurl [ "java script:OnJSEvent( )" ] field MFString param [ "" "" ] eventIn SFTime clicked eventIn SFTime set_string eventOut SFRotation rotation_changed url "vrmlscript: function clicked (value, time) { angle = Math.random()*6.283; rotation_changed = new SFRotation(0,1,0,angle); } function set_string (value, time) { newurl[0] = 'OnEvent ( ' + 'your par1 ' + ',' + 'your par2' + ')'; Browser.loadURL (newurl,param); } " } ] } Transform { translation 0 -3 0 children [ DEF ChangeString Text { string "ChangeString" } ] } Script { url "vrmlscript: function initialize() {}" } # apparramment pas d'influence dans le deroulement de javascript ROUTE RotSensor.touchTime TO RotationScript.clicked ROUTE RotSensor.touchTime TO RotationScript.set_string ROUTE RotationScript.rotation_changed TO SharedRotation.set_rotation ROUTE RotationScript.rotation_changed TO BoxRotation.set_rotation ROUTE SharedRotation.rotation_changed TO BoxRotation.rotation ROUTE ColorSensor.touchTime TO ColorScript.clicked ROUTE ColorScript.color_changed TO SharedColor.set_color ROUTE SharedColor.color_changed TO BoxColor.diffuseColor ROUTE ColorScript.color_changed_from_bot TO BoxColor.diffuseColor ROUTE SharedColor.string_changed TO ColorScript.changeColor -->
Fenrir

2005-02-15, 11:21 pm

Topo Vrml 3D, javascriptpage1.html : http://perso.wanadoo.fr/promethee60/3D/page1.html

marche en locale ; retourne une erreur sur le serveur ???

sample.wrl http://perso.wanadoo.fr/promethee60/3D/sample.wrl
l'erreur vient du code bs contact au lieu de blaxxun ??

Note de synthese sur vrml, js et eai
http://perso.wanadoo.fr/promethee60/3D/topo.html


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews