Computer Graphics Group David Sedláček. Computer Graphics Group 2X3D Contents 1.DOM manipulation 2.Events 3.Animation 4.Prototypes 5.Augmented Reality.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

JavaScript – Quiz #8 Lecture Code:
The jQuery library. What is jQuery ? A javascript lightweight library Is very easy to use Is powerful Is cross-browser compatible Downloadable from jQuery.com,
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
© Fraunhofer IGD Introduction and Tutorial X3DOM – Declarative (X)3D in HTML5 Yvonne Jung, Johannes Behr Fraunhofer IGD / VCST Darmstadt, Germany.
JQuery CS 380: Web Programming. What is jQuery? jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling,
Multimedia and the WWW Howell Istance and Chris Hand, Napier University.
© De Montfort University, D Graphics and VRML Howell Istance and Chris Hand* De Montfort University * now at
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
CST JavaScript Validating Form Data with JavaScript.
Microsoft Certification Exam Michael Van Cleave Planet Technologies.
Computer Graphics Group Jiří Žára. Computer Graphics Group 2X3D Contents 1.Web3D Consortium 2.X3D specification 3.GeoVRML 4.NurbsVRML 2.
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
Learning & Development Telerik Software Academy.
Computer Graphics Group Jiří Žára & David Sedláček.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Sascha Wener.  Definition from Microsoft Developer Network: “A theme is a unified set of design elements and color schemes that you apply to pages to.
JQuery March 09 th,2009 Create by
VRML - 1 Virtual Reality Modeling Language (VRML) Peter O’Grady.
JQuery 10/21. Today jQuery Some cool tools around the web JavaScript Libraries Drawing libraries HTML Frameworks Conventions.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
Interacting with a Web Page using JavaScript Mat Kelly GTAI Presentation January 10, 2014.
Lab 3: Language Structures User Interface Lab: GUI Lab Sep. 9 th, 2014.
H3D API Training  Part 3.3: Python – H3D integration.
WRT235: Writing in Electronic Environments Basic CSS.
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
ALBERT WAVERING BOBBY SENG. Week 5: More JavaScript  Quiz  Announcements/questions.
Computer Graphics Group Jiří Žára. Computer Graphics Group 2X3D Contents 1.Web3D Consortium 2.X3D specification 3.GeoVRML 4.NurbsVRML 2.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
Computer Graphics Group Script node Jiří Žára. Computer Graphics Group Contents 1.Script node 2.Motion generators 2Script node.
JQuery Youn-Hee Han
A Multi-agent Approach for the Integration of the Graphical and Intelligent Components of a Virtual Environment Rui Prada INESC-ID.
Review for exam 1 Midterm Closed Book. Review for Exam 1 Blackboard topic Review for exam 1 Sample Question Multiple Choice True / False Matching type.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
© TMC Computer School HC20203 VRML HIGHER DIPLOMA IN COMPUTING Chapter 2 – Basic VRML.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
© Fraunhofer IGD Introduction and Tutorial X3DOM – Declarative (X)3D in HTML5 Yvonne Jung Fraunhofer IGD Darmstadt, Germany
Positioning Objects with CSS and Tables
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
CS 490: Computer Graphics Graphics Programming and HTML Canvas.
Project 7: Exploring DHTML Essentials for Design JavaScript Level Two Michael Brooks.
Selectors & Events. What do Selectors do? What do Selectors do? Selectors allow you to manipulate DOM elements as a group or as a single node. This allows.
© TMC Computer School HC20203 VRML HIGHER DIPLOMA IN COMPUTING Chapter 5 – Animation in VRML.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
JQuery is a fast, small, and feature-rich javascript library. It makes things like HTML document traversal and manipulation, event handling, animation,
JQuery Element & Attribute Selectors, Events, HTML Manipulation, & CSS Manipulation.
X3DOM : Integrating 3D content seamlessly into webpage
SVG & DOM Manipulation via Javascript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
MPEG-4 Binary Information for Scenes (BIFS)
JQUERY Online TRAINING AT GOLOGICA
Web3D Consortium X3DOM: Next-Generation Web3D Applications on Open Standards and Open Source Web3D Consortium
14 A Brief Look at JavaScript and jQuery.
Introduction to Programming the WWW I
Javascript and JQuery SRM DSC.
HTML / CSS Mai Moustafa Senior Web Designer eSpace eSpace.
Introduction to JavaScript & jQuery
Lecture 3. Virtual Worlds : Representation,Creation and Simulation
Presentation transcript:

Computer Graphics Group David Sedláček

Computer Graphics Group 2X3D Contents 1.DOM manipulation 2.Events 3.Animation 4.Prototypes 5.Augmented Reality 2

Computer Graphics Group DOM manipulation 3X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also DOM Manipulation: setting attributes JS manipulation: document.getElementById(‘mat’).setAttribute(‘diffuseColor’,’green’); document.getElementById(‘redBox’).setAttribute(‘size’,’1 2 3’); document.getElementById(‘boxTR’).setAttribute(‘rotation’,’ ’); document.getElementById(“inID”).setAttribute(“url”,”path/model.x3d”) ; - This cause replacing of inlined geometry “immediately”

Computer Graphics Group id / DEF 4X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also 1.If both id and DEF are set both attributes will have different values 2.If only DEF is given id is unset 3.If only id is given DEF and id will be set … Test (valid/invalid): document.getElementById(‘trNode’); document.getElementById(‘o1’);

Computer Graphics Group Attributes cont. 5X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also How to read attribute ? document.getElementById(‘redBox’).getAttribute(‘size’); How to access inlined elements ? Define nameSpaceName To access nodes nameSpaceName.”__”.inlinedNodeID (two underscores) document.getElementById(‘carusel__mat’).getAttribute(‘…’); Test it !

Computer Graphics Group DOM mani. - jQuery js Library for simpler DOM manipulation – –CSS-like selectors document.getElementById(‘mat’).getAttribute(‘diffuseColor’); $(‘#mat’).prop(‘diffuseColor’); -do not use $(‘#mat’).attr(‘diffuseColor’); document.getElementById(‘mat’).setAttribute(‘diffuseColor’,’green’); $(‘#mat’).prop(‘diffuseColor’,’green’); document.getElementById(‘redBox’).getElementsByTagName(‘material’)[0].getAttribute(‘diffuseColor’); $(‘#redBoxShp material’).prop(‘diffuseColor’); 6X3D

Computer Graphics Group DOM manipulation 7X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also Node appending / removal JS to add nodes: root = document.getElementById(‘root’); trans = document.createElement(‘Transform’); trans.setAttribute(‘translation’, ‘1 2 3’); root.appendChild(trans); JS to remove nodes: root.removeChild(trans);

Computer Graphics Group Events 8X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also HTML Events: User Interaction through DOM Events <box id=“redBox” onclick=“document.getElementById(‘mat’). setAttribute(‘diffuseColor’,’green’);” > Test it !

Computer Graphics Group Events cont. 9X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also document.onload = function() { document.getElementById(‘redBox').addEventListener('click', function() { document.getElementById('mat').setAttribute('diffuseColor', ‘green'); }, false) }; Test it !

Computer Graphics Group Animation control Similar to VRML –Time sensor –Setting time of the event (in sec) –new EventIn: pauseTime, resumeTime document.getElementById("timeS").setAttribute("startTime", (new Date()).getTime()/1000 ); 10X3D Test it !

Computer Graphics Group Animation - js Other animation types – by JavaScript anim. – setTimeOut(method,500) do method() 500 ms from now – setInterval(method,500) do method() every 500 ms until stoped anim.start = function() {anim.timer = setInterval(anim.anime,20)}; anim.stop = function() {clearInterval(anim.timer); anim.timer = null;}; anim.anime = function() { h = anim.height * Math.sin(anim.iter*anim.speedFactor*Math.PI); anim.iter++; document.getElementById('boxTr').setAttribute ('translation','0 '+h+' 0'); }; 11X3D Test it !

Computer Graphics Group Animation - js Reaction on changed values –Write own method which check time to time, that some values has changed –jQuery – watch plugin Not working properly with X3Dom TimeSensor and Interpolators $('#boxTr').watch('translation', function() { $('#info').html( $(this).prop('translation') ); }); 12X3D Test it !

Computer Graphics Group Followers X3D animation nodes Interpolates from current value to destination –DAMPERS color, coordinate, orientation, position, position2D, texCoord no end of transition, approach destination asymptotically but very quickly ease-in and asymptotic ease-out –CHASERS orientation, position, position2D, scalar terminate after given amount of time ease-in and ease-out 13X3D Test it !

Computer Graphics Group Followers – cont. –Followers (abstract node) event-in: set_destination, set_value event-out: isActive, value_changed fields: initialDestination, initialValue –CHASERS field: SFTime duration [0;inf) –DAMPERS fields: SFTime tau [0;inf), SFFloat tolerance ( -1 or [0;inf) ) js: document.getElementById("pda").setAttribute("set_destination",pos); 14X3D Test it !

Computer Graphics Group Prototypes – 1) Inlined files –each inlined file has own namespace –change object properties after inline load <inline id="box1id" url="./x3d_files/colorBox.x3d" onload="box1Loaded();" nameSpaceName="box1"> function box1Loaded() { var box = getInlinedElement('box1', 'barevnaKrychle'); box.getElementsByTagName('Material')[0].setAttribute('diffuseColor','0 0 1'); } function getInlinedElement(inName, id) { return document.getElementById(inName+'__'+id); } 15X3D object id used in X3D file Test it !

Computer Graphics Group Prototypes – 2) PROTO nodes - reinterpretation 16X3D Test it ! prepare interface, default values document.getElementsByTagName(‘colorBox’); element.getElementsByTagName(‘IS’); element = protoBody.child[i].cloneNode(true); protoInstance.parentNode.appendChild(element); Test it !

Computer Graphics Group HUD Heads-Up Display –Displays information as a part of user interface –HTML5 elements styled by CSS Can be nested in X3D element Absolute positioning Z-index higher then scene z-index Empty DIVs block X3Dom interaction 17X3D Test it !

Computer Graphics Group Runtime API var e = document.getElementById('the_x3delement'); e.runtime.showAll(); The runtime api provides programmatic live access to the system –View controls: nextView(); prevView(); showAll(); … –Projections and Picking: viewMatrix(); getWorldToCameraCoordinatesMatrix(); getViewingRay(x,y); PickRect(x1,y1,x2,y2); … –Callbacks: noBackendFound(); ready(); enterFrame(); More at: 18X3D Test it !

Computer Graphics Group Math js object Math for trivial mathematical tasks var x = Math.PI; var y = Math.sqrt(16); X3Dom.js - support for vectors, matrices,… –developers docs var norm = new x3dom.fields.SFVec3f(event.normalX, event.normalY, event.normalZ); var qDir = x3dom.fields.Quaternion.rotateFromTo(new x3dom.fields.SFVec3f(0, -1, 0), norm); var rot = qDir.toAxisAngle(); t.setAttribute('rotation', rot[0].x+' '+rot[0].y+' '+rot[0].z+' '+rot[1]); 19X3D

Computer Graphics Group X3DOM Math Lib SFVec3f copy(v) parse(str) setValues(that) at(i) add(that) addScaled(that,s) subtract(that) negate() dot(that) cross(that) reflect(n) length() normalize(that) multComponents(that) multiply(n) divide(n) equals(that,eps) toGL() toString() setValueByStr(str) Titel, Ort, Datum - Vorname Name 20 Quaternion parseAxisAngle(str) axisAngle(axis,a) rotateFromTo(fromVec,toVec) multiply(that) toMatrix() toAxisAngle() angle() setValue(matrix) dot(that) add(that) subtract(that) setValues(that) equals(that,eps) multScalar(s) normalize(that) negate() inverse() slerp(that,t) toGL() toString() setValueByStr(str) SFColor parse(str) colorParse(color) setValues(color) equals(that,eps) add(that) subtract(that) multiply(n) toGL() toString() setValueByStr(str) SFColorRGBA parse(str) setValues(color) equals(that,eps) toGL() toString() setValueByStr(str)

Computer Graphics Group X3DOM Math Lib SFMatrix4f copy(that) identity() zeroMatrix() translation(vec) rotationX(a) rotationY(a) rotationZ(a) scale(vec) lookAt(from,at,up) parseRotation(str) parse(str) e0() e1() e2() e3() setTranslate(vec) setScale(vec) Titel, Ort, Datum - Vorname Name 21 mult(that) multMatrixPnt(vec) multMatrixVec(vec) multFullMatrixPnt(vec) transpose() negate() multiply(s) add(that) addScaled(that,s) setValues(that) setValue(v1,v2,v3,v4) toGL() at(i,j) sqrt() normInfinity() norm1_3x3() normInf_3x3() adjointT_3x3() equals(that) getTransform(translation, rotation,scaleFactor, scaleOrientation,center) decompose(t,r,s,so) polarDecompose(Q,S) spectralDecompose(SO,k) log() exp() det3(a1,a2,a3,b1,b2,b3, c1,c2,c3) det() inverse() toString() setValueByStr(str) Example Basic decomposition of x3dom.fields.SFMatrix4f (given as mat) var quat = new x3dom.fields.Quaternion(0, 0, 1, 0); quat.setValue(mat); var rotation = rot.toAxisAngle(); var translation = mat.e3(); Example Basic decomposition of x3dom.fields.SFMatrix4f (given as mat) var quat = new x3dom.fields.Quaternion(0, 0, 1, 0); quat.setValue(mat); var rotation = rot.toAxisAngle(); var translation = mat.e3();

Computer Graphics Group AR & X3Dom ? 22X3D Inspired by X3Dom talk at Fraunhofer IGD (Sep. 2012), texts and images are adapted from the talk also No problem 1.Video capture & display WebRTC MediaStream API 2.Object detection Marker tracking JSARToolkit (JavaScript AR Toolkit) 3.3D real-time rendering X3Dom Test it !

Computer Graphics Group AR & X3Dom ? 23X3D camera Marker detector HUD if we want 3D scene function set_marker_transform(value) { document.getElementById(‘rootT’).setAttribute(matrix, value); } flash javaScript X3Dom trigger

Computer Graphics Group 24X3D … end of this part 24 David Sedláček November 2013