├── .editorconfig ├── .eslintrc.json ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .prettierrc ├── .travis.yml ├── Gruntfile.js ├── LICENSE ├── README.md ├── benchmarks ├── benchmarks.js ├── index.html ├── mockupBench.js ├── osg │ ├── Geometry.js │ ├── Visitor.js │ ├── mainPerformance.js │ └── osgBenchmarks.js ├── osgAnimation │ └── mainPerformance.js ├── reportStats.js └── runBenchmarks.js ├── examples ├── animate-lightcolor │ ├── index.html │ └── main.js ├── animate-rotation │ ├── index.html │ └── main.js ├── animate-transparency │ ├── index.html │ └── main.js ├── animation │ ├── index.html │ └── main.js ├── basic-transform │ ├── index.html │ └── main.js ├── camera-gallery │ ├── index.html │ └── main.js ├── camera │ ├── index.html │ ├── main.js │ └── textures │ │ └── sol_trauma_periph.png ├── cubemotion │ ├── image.png │ ├── index.html │ └── main.js ├── customshader │ ├── index.html │ └── main.js ├── dragndrop │ ├── index.html │ └── main.js ├── drawbuffers │ ├── index.html │ └── main.js ├── files.js ├── findnode-visitor │ ├── index.html │ └── main.js ├── frustum-culling │ ├── index.html │ └── main.js ├── geometry │ ├── index.html │ └── main.js ├── gizmo │ ├── index.html │ └── main.js ├── hdr │ ├── index.html │ ├── main.js │ └── textures │ │ ├── Alexs_Apartment │ │ ├── Alexs_Apt_2k.hdr │ │ ├── Alexs_Apt_2k.png │ │ ├── Alexs_Apt_Env.hdr │ │ └── Alexs_Apt_Env.png │ │ ├── Arches_E_PineTree │ │ ├── Arches_E_PineTree_3k.hdr │ │ ├── Arches_E_PineTree_3k.png │ │ ├── Arches_E_PineTree_Env.hdr │ │ └── Arches_E_PineTree_Env.png │ │ ├── GrandCanyon_C_YumaPoint │ │ ├── GCanyon_C_YumaPoint_3k.hdr │ │ ├── GCanyon_C_YumaPoint_3k.png │ │ ├── GCanyon_C_YumaPoint_Env.hdr │ │ └── GCanyon_C_YumaPoint_Env.png │ │ ├── Milkyway │ │ ├── Milkyway_Light.hdr │ │ ├── Milkyway_Light.png │ │ ├── Milkyway_small.hdr │ │ └── Milkyway_small.png │ │ ├── PaperMill_Ruins_E │ │ └── PaperMill_E_3k.hdr │ │ ├── Tropical_Ruins │ │ └── TropicalRuins_3k.hdr │ │ └── Walk_Of_Fame │ │ ├── Mans_Outside_2k.hdr │ │ ├── Mans_Outside_2k.png │ │ ├── Mans_Outside_Env.hdr │ │ └── Mans_Outside_Env.png ├── lights │ ├── index.html │ └── main.js ├── load-model │ ├── index.html │ └── main.js ├── materials │ ├── index.html │ └── main.js ├── morph │ ├── index.html │ └── main.js ├── multi-viewport-rtt │ ├── index.html │ └── main.js ├── multiplelights │ ├── index.html │ └── main.js ├── multipleviewers │ ├── index.html │ └── main.js ├── pagedlod │ ├── index.html │ └── main.js ├── pbr │ ├── Environment.js │ ├── EnvironmentCubeMap.js │ ├── EnvironmentPanorama.js │ ├── EnvironmentSphericalHarmonics.js │ ├── IntegrateBRDF.js │ ├── README.md │ ├── index.html │ ├── main.js │ └── shaders │ │ ├── colorSpace.glsl │ │ ├── cubemapFragment.glsl │ │ ├── cubemapSampler.glsl │ │ ├── cubemapVertex.glsl │ │ ├── math.glsl │ │ ├── panoramaFragment.glsl │ │ ├── panoramaSampler.glsl │ │ ├── panoramaVertex.glsl │ │ ├── pbrReferenceFragment.glsl │ │ ├── pbrReferenceVertex.glsl │ │ ├── pbr_ue4.glsl │ │ ├── sphericalHarmonics.glsl │ │ ├── sphericalHarmonicsFragment.glsl │ │ └── sphericalHarmonicsVertex.glsl ├── performance │ ├── index.html │ ├── main.js │ └── textures │ │ └── texture.png ├── picking │ ├── index.html │ └── main.js ├── postprocess │ ├── index.html │ ├── main.js │ └── shaders │ │ ├── blackAndWhite.glsl │ │ ├── blackAndWhite.json │ │ ├── colorBalance.glsl │ │ ├── colorBalance.json │ │ ├── colorBalanceLUT.glsl │ │ ├── colorCorrection.glsl │ │ ├── colorCorrection.json │ │ ├── sampleLUT.glsl │ │ ├── ssao.json │ │ ├── ssaoBlur.glsl │ │ ├── ssaoExtract.glsl │ │ ├── vignette.glsl │ │ └── vignette.json ├── quad-texture │ ├── index.html │ └── main.js ├── scene-debug │ ├── index.html │ └── main.js ├── screenshot │ ├── index.html │ └── main.js ├── shader-generator │ ├── CustomCompiler.js │ ├── index.html │ ├── main.js │ ├── negatif.js │ ├── ramp.js │ └── shaders │ │ └── custom.glsl ├── shadowmap │ ├── custom.glsl │ ├── debug.glsl │ ├── index.html │ ├── main.js │ ├── pcf.glsl │ └── pcss.glsl ├── sound-3d │ ├── index.html │ ├── main.js │ └── sound.js ├── split-rendering-rtt │ ├── index.html │ └── main.js ├── templates │ ├── Example.js │ ├── css │ │ ├── base.css │ │ └── sidebar.css │ ├── index-dark.html │ ├── index-light.html │ └── main.js ├── text2D │ ├── index.html │ └── main.js ├── texture-video │ ├── index.html │ └── main.js ├── usercamera │ ├── index.html │ └── main.js └── webVR │ ├── fullscreen.js │ ├── ic_cardboard_white_24dp.svg │ ├── ic_fullscreen_exit_white_24dp.svg │ ├── index.html │ └── main.js ├── index.html ├── package.json ├── sources ├── OSG.js ├── config.js ├── osg │ ├── AutoTransform.js │ ├── BillboardAttribute.js │ ├── BlendColor.js │ ├── BlendFunc.js │ ├── BoundingBox.js │ ├── BoundingSphere.js │ ├── BufferArray.js │ ├── BufferArrayProxy.js │ ├── Camera.js │ ├── ColorMask.js │ ├── ComputeBoundsVisitor.js │ ├── CullFace.js │ ├── CullSettings.js │ ├── CullStack.js │ ├── CullVisitor.js │ ├── CullingSet.js │ ├── Depth.js │ ├── DrawArrayLengths.js │ ├── DrawArrays.js │ ├── DrawElements.js │ ├── EllipsoidModel.js │ ├── FrameBufferObject.js │ ├── FrameStamp.js │ ├── GLObject.js │ ├── Geometry.js │ ├── Image.js │ ├── ImageStream.js │ ├── KdTree.js │ ├── KdTreeBuilder.js │ ├── Light.js │ ├── LightSource.js │ ├── LineWidth.js │ ├── Lod.js │ ├── Material.js │ ├── MatrixTransform.js │ ├── Node.js │ ├── NodeVisitor.js │ ├── Object.js │ ├── Options.js │ ├── PagedLOD.js │ ├── Plane.js │ ├── PointSizeAttribute.js │ ├── Polytope.js │ ├── PooledArray.js │ ├── PooledMap.js │ ├── PooledResource.js │ ├── Program.js │ ├── Projection.js │ ├── RenderBin.js │ ├── RenderLeaf.js │ ├── RenderStage.js │ ├── Scissor.js │ ├── Shader.js │ ├── StackObjectPairPool.js │ ├── State.js │ ├── StateAttribute.js │ ├── StateCache.js │ ├── StateGraph.js │ ├── StateSet.js │ ├── Switch.js │ ├── Texture.js │ ├── TextureCubeMap.js │ ├── TextureManager.js │ ├── Timer.js │ ├── TimerGPU.js │ ├── Transform.js │ ├── TriangleIndexFunctor.js │ ├── Uniform.js │ ├── UpdateVisitor.js │ ├── VertexArrayObject.js │ ├── Viewport.js │ ├── WebGLCaps.js │ ├── computeMatrixFromNodePath.js │ ├── cullVisitorHelper.js │ ├── glMatrix.js │ ├── math.js │ ├── notify.js │ ├── osg.js │ ├── polyfill.js │ ├── primitiveFunctor.js │ ├── primitiveIndexFunctor.js │ ├── primitiveSet.js │ ├── shape.js │ ├── transformEnums.js │ └── utils.js ├── osgAnimation │ ├── AnimationUpdateCallback.js │ ├── BasicAnimationManager.js │ ├── Bone.js │ ├── CollectAnimationUpdateCallbackVisitor.js │ ├── CollectBoneVisitor.js │ ├── FindNearestParentSkeleton.js │ ├── MorphAttribute.js │ ├── MorphGeometry.js │ ├── RigGeometry.js │ ├── RigTransformHardware.js │ ├── Skeleton.js │ ├── SkinningAttribute.js │ ├── StackedMatrix.js │ ├── StackedQuaternion.js │ ├── StackedRotateAxis.js │ ├── StackedScale.js │ ├── StackedTranslate.js │ ├── UpdateBone.js │ ├── UpdateMatrixTransform.js │ ├── UpdateMorph.js │ ├── UpdateRigGeometry.js │ ├── UpdateSkeleton.js │ ├── animation.js │ ├── channel.js │ ├── channelType.js │ ├── easing.js │ ├── interpolator.js │ ├── osgAnimation.js │ └── target.js ├── osgDB │ ├── DatabasePager.js │ ├── Input.js │ ├── Registry.js │ ├── fileHelper.js │ ├── options.js │ ├── osgDB.js │ ├── readerParser.js │ ├── requestFile.js │ └── zlib.js ├── osgGA │ ├── CADManipulator.js │ ├── CADManipulatorHammerController.js │ ├── CADManipulatorStandardMouseKeyboardController.js │ ├── Controller.js │ ├── FirstPersonManipulator.js │ ├── FirstPersonManipulatorDeviceOrientationController.js │ ├── FirstPersonManipulatorHammerController.js │ ├── FirstPersonManipulatorStandardMouseKeyboardController.js │ ├── FirstPersonManipulatorWebVRController.js │ ├── Manipulator.js │ ├── OrbitManipulator.js │ ├── OrbitManipulatorDeviceOrientationController.js │ ├── OrbitManipulatorGamePadController.js │ ├── OrbitManipulatorHammerController.js │ ├── OrbitManipulatorStandardMouseKeyboardController.js │ ├── OrbitManipulatorWebVRController.js │ ├── SwitchManipulator.js │ ├── orbitManipulatorEnums.js │ └── osgGA.js ├── osgNameSpace.js ├── osgPlugins │ ├── ReaderWriterGLTF.js │ ├── ReaderWriterZIP.js │ └── osgPlugins.js ├── osgShader │ ├── Compiler.js │ ├── CompilerFragment.js │ ├── CompilerVertex.js │ ├── ShaderGenerator.js │ ├── ShaderGeneratorProxy.js │ ├── ShaderProcessor.js │ ├── node │ │ ├── Node.js │ │ ├── billboard.glsl │ │ ├── colorEncode.glsl │ │ ├── common.glsl │ │ ├── data.js │ │ ├── functions.glsl │ │ ├── lightCommon.glsl │ │ ├── lights.glsl │ │ ├── morphing.glsl │ │ ├── operations.js │ │ ├── skinning.glsl │ │ └── textures.glsl │ ├── nodeFactory.js │ ├── osgShader.js │ ├── shaderLib.js │ └── utils.js ├── osgShadow │ ├── ShadowCastAttribute.js │ ├── ShadowCastCompiler.js │ ├── ShadowCastShaderGenerator.js │ ├── ShadowCasterVisitor.js │ ├── ShadowFrustumIntersection.js │ ├── ShadowMap.js │ ├── ShadowMapAtlas.js │ ├── ShadowReceiveAttribute.js │ ├── ShadowSettings.js │ ├── ShadowTechnique.js │ ├── ShadowTexture.js │ ├── ShadowTextureAtlas.js │ ├── ShadowedScene.js │ ├── osgShadow.js │ ├── shaderLib.js │ └── shaders │ │ ├── floatFromTex.glsl │ │ ├── shadowCast.glsl │ │ ├── shadowLinearSoft.glsl │ │ ├── shadowReceive.glsl │ │ └── tapPCF.glsl ├── osgStats │ ├── BufferStats.js │ ├── Counter.js │ ├── Graph.js │ ├── Stats.js │ ├── TextGenerator.js │ ├── browserStats.js │ ├── defaultStats.js │ ├── glStats.js │ └── osgStats.js ├── osgText │ ├── Text.js │ └── osgText.js ├── osgUtil │ ├── ComposerPostProcess.js │ ├── DelayInterpolator.js │ ├── DisplayGeometryVisitor.js │ ├── DisplayGraph.js │ ├── DisplayGraphNode.js │ ├── DisplayGraphRenderer.js │ ├── DisplayNormalVisitor.js │ ├── IntersectFunctor.js │ ├── IntersectionVisitor.js │ ├── Intersector.js │ ├── LineSegmentIntersectFunctor.js │ ├── LineSegmentIntersector.js │ ├── NodeGizmo.js │ ├── PolytopeIntersectFunctor.js │ ├── PolytopeIntersector.js │ ├── SphereIntersectFunctor.js │ ├── SphereIntersector.js │ ├── TangentSpaceGenerator.js │ ├── WebVR.js │ ├── WebVRCustom.js │ ├── debug.js │ ├── gizmoGeometry.js │ ├── intersectionEnums.js │ ├── osgUtil.js │ └── webvr-1-1.js ├── osgViewer │ ├── Renderer.js │ ├── Scene.js │ ├── View.js │ ├── Viewer.js │ ├── input │ │ ├── InputConstants.js │ │ ├── InputManager.js │ │ └── source │ │ │ ├── InputSource.js │ │ │ ├── InputSourceDeviceOrientation.js │ │ │ ├── InputSourceGamePad.js │ │ │ ├── InputSourceKeyboard.js │ │ │ ├── InputSourceMouse.js │ │ │ ├── InputSourceTouchScreen.js │ │ │ └── InputSourceWebVR.js │ ├── osgViewer.js │ ├── webgl-debug.js │ └── webgl-utils.js └── osgWrappers │ ├── osgWrappers.js │ └── serializers │ ├── osg.js │ ├── osgAnimation.js │ └── osgText.js ├── tests ├── index.html ├── mockup │ ├── InputMockup.js │ ├── box.js │ ├── greyscale.png │ ├── mockup.js │ ├── mockupForNode.js │ ├── multistream.bin │ ├── rgb24.png │ ├── rgba32.png │ ├── scene.js │ └── stream.bin ├── osg │ ├── BlendColor.js │ ├── BoundingBox.js │ ├── BoundingSphere.js │ ├── BufferArray.js │ ├── BufferArrayProxy.js │ ├── Camera.js │ ├── ComputeBoundsVisitor.js │ ├── ComputeMatrixFromNodePath.js │ ├── CullFace.js │ ├── CullVisitor.js │ ├── Depth.js │ ├── FrameBufferObject.js │ ├── Image.js │ ├── KdTree.js │ ├── Light.js │ ├── Matrix.js │ ├── MatrixTransform.js │ ├── Node.js │ ├── NodeVisitor.js │ ├── PagedLOD.js │ ├── Plane.js │ ├── Quat.js │ ├── Shader.js │ ├── State.js │ ├── StateSet.js │ ├── Switch.js │ ├── Texture.js │ ├── TextureCubeMap.js │ ├── TextureManager.js │ ├── Uniform.js │ ├── UpdateVisitor.js │ ├── Utils.js │ ├── WebGLCaps.js │ ├── osgTests.js │ └── primitiveFunctor.js ├── osgAnimation │ ├── BasicAnimationManager.js │ ├── Interpolator.js │ ├── StackedTransform.js │ └── osgAnimationTests.js ├── osgDB │ ├── DatabasePager.js │ ├── Input.js │ ├── ReaderParser.js │ └── osgDBTests.js ├── osgGA │ ├── FirstPersonManipulator.js │ ├── OrbitManipulator.js │ └── osgGATests.js ├── osgShader │ ├── Compiler.js │ ├── ShaderGenerator.js │ └── osgShaderTests.js ├── osgShadow │ ├── ShadowMap.js │ ├── ShadowedScene.js │ └── osgShadowTests.js ├── osgText │ ├── Text.js │ └── osgTextTests.js ├── osgUtil │ ├── IntersectionVisitor.js │ ├── LineSegmentIntersectFunctor.js │ ├── LineSegmentIntersector.js │ ├── PolytopeIntersector.js │ ├── SphereIntersector.js │ └── osgUtilTests.js ├── osgViewer │ ├── Inputs.js │ ├── View.js │ ├── Viewer.js │ └── osgViewerTests.js ├── osgWrappers │ ├── osgAnimation.js │ └── osgWrappersTests.js ├── runTests.js └── tests.js ├── webpack.config.js └── website ├── CNAME ├── build-website.sh ├── build-wintersmith.js ├── config.json ├── contents ├── api-documentation.md ├── assets │ ├── about.png │ ├── favicon.png │ ├── img │ │ ├── animation.jpg │ │ ├── camera.jpg │ │ ├── cubemotion.jpg │ │ ├── demojs-fff.jpg │ │ ├── dualcam.jpg │ │ ├── earlyz.jpg │ │ ├── frustum-culling.jpg │ │ ├── gizmo.jpg │ │ ├── globetweeter.jpg │ │ ├── hdr.jpg │ │ ├── lights.jpg │ │ ├── materials.jpg │ │ ├── multipleviewers.jpg │ │ ├── nouvellevague.jpg │ │ ├── pbr.jpg │ │ ├── performance.jpg │ │ ├── peter.jpg │ │ ├── picking.jpg │ │ ├── plod.jpg │ │ ├── pointcloudviz.jpg │ │ ├── postproc.jpg │ │ ├── scene-debug.jpg │ │ ├── shader-generator.jpg │ │ ├── shadowmap.jpg │ │ ├── sketchfab.jpg │ │ ├── sound3d.jpg │ │ ├── ssao.jpg │ │ ├── terrain.jpg │ │ ├── text2D.jpg │ │ ├── texture-video.jpg │ │ └── veditor.jpg │ ├── logo.png │ └── screen.css ├── concepts.md ├── examples.md ├── getting-started.md ├── index.md ├── installation.md ├── projects.md └── support.md ├── push-website.sh └── templates └── index.html /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 4 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.js] 21 | indent_style = space 22 | indent_size = 4 23 | 24 | [*.glsl] 25 | indent_style = space 26 | indent_size = 4 27 | 28 | [*.md] 29 | trim_trailing_whitespace = false 30 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.hdr binary 2 | *.jpg binary 3 | *.osgjs binary 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | .DS_Store 3 | node_modules 4 | qunit 5 | sandbox 6 | *~ 7 | bugs 8 | data 9 | doc 10 | test/quat 11 | test/pick 12 | test/matrix 13 | test/lighting 14 | *.cpp 15 | *.osg 16 | *.log 17 | *.c 18 | *.orig 19 | *Thumbs.db 20 | .hooks 21 | .tern-port 22 | builds 23 | builds/active 24 | builds/active/OSG.js 25 | builds/active/OSG.js.map 26 | builds/dist/OSG.js 27 | builds/dist/OSG.js.map 28 | sources/version.js 29 | examples/media/* 30 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "examples/media"] 2 | path = examples/media 3 | url = https://github.com/cedricpinson/osgjs-data 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "bracketSpacing": true, 4 | "tabWidth": 4, 5 | "printWidth": 100, 6 | "trailingComma": "none" 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | env: 2 | global: 3 | # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created 4 | # via the "travis encrypt" command using the project repo's public key 5 | - secure: "kEKxAxixWjqtwAgPfKQzABJ6wpnk+52l1gRMCp6H5OFbuQws+MrKAS4YO2CgGdfjufioQFIlExfoCbK4GD6CXp11HAO9p8YGgcJxT1cQ5TRXHbZhz96EayrXoKdUq4s+UCaZUbBQsSuMdpPFZojrk8TKj/mzv6B+dbFz4RJrG8o=" 6 | language: node_js 7 | sudo: false 8 | node_js: 9 | - "7.5.0" 10 | 11 | addons: 12 | coverity_scan: 13 | project: 14 | name: "cedricpinson/osgjs" 15 | description: "Build submitted via Travis CI" 16 | notification_email: trigrou@trigrou.com 17 | build_command: "--no-command --fs-capture-search ./sources/" 18 | branch_pattern: coverity_scan 19 | 20 | 21 | install: 22 | - npm install 23 | - npm install -g npm@latest 24 | - npm install -g grunt 25 | - npm install -g grunt-cli 26 | 27 | script: if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then grunt check --verbose && grunt build --verbose && grunt test --verbose ; fi 28 | 29 | 30 | notifications: 31 | webhooks: 32 | urls: 33 | - https://webhooks.gitter.im/e/3ccc58feb42775e3c408 34 | on_success: change # options: [always|never|change] default: always 35 | on_failure: always # options: [always|never|change] default: always 36 | on_start: false # default: false 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright © 2015 OSGJS Cedric Pinson and OSGJS contributors ( https://github.com/cedricpinson/osgjs/graphs/contributors ) 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /benchmarks/benchmarks.js: -------------------------------------------------------------------------------- 1 | import { osg } from 'OSG'; 2 | import osgBenchmarks from 'benchmarks/osg/osgBenchmarks'; 3 | 4 | // add missing class for phantom js execution context 5 | if (window.HTMLVideoElement === undefined) { 6 | // dummy class 7 | window.HTMLVideoElement = function() {}; 8 | } 9 | 10 | osg.setNotifyLevel(osg.ERROR); 11 | 12 | osgBenchmarks(); 13 | -------------------------------------------------------------------------------- /benchmarks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mocha 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /benchmarks/osg/Geometry.js: -------------------------------------------------------------------------------- 1 | import Shape from 'osg/shape'; 2 | import Timer from 'osg/Timer'; 3 | import reportStats from 'benchmarks/reportStats'; 4 | 5 | export default function() { 6 | test('ComputeBound', function() { 7 | // 250 * 250 * 6 = 375k vertices (draw arrays...) 8 | var geom = Shape.createTexturedSphere(1.0, 250, 250); 9 | var timed = Timer.instance().tick(); 10 | 11 | console.profile(); 12 | console.time('time'); 13 | 14 | var nCount = 5; 15 | for (var n = 0; n < nCount; n++) { 16 | geom.dirtyBound(); 17 | geom.getBound(); 18 | } 19 | 20 | console.timeEnd('time'); 21 | console.profileEnd(); 22 | 23 | timed = Timer.instance().tick() - timed; 24 | 25 | reportStats(timed, 'ComputeBound'); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /benchmarks/osg/osgBenchmarks.js: -------------------------------------------------------------------------------- 1 | import MainPerformance from 'benchmarks/osg/mainPerformance'; 2 | import Geometry from 'benchmarks/osg/Geometry'; 3 | import Visitor from 'benchmarks/osg/Visitor'; 4 | 5 | export default function() { 6 | suite('MainPerformance'); 7 | MainPerformance(); 8 | 9 | suite('Visitor'); 10 | Visitor(); 11 | 12 | suite('Geometry'); 13 | Geometry(); 14 | } 15 | -------------------------------------------------------------------------------- /benchmarks/reportStats.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('chai').assert; 3 | 4 | module.exports = function(timed, perfTarget, msg) { 5 | var logMsg = msg; 6 | if (logMsg === undefined) { 7 | logMsg = 8 | 'perf' + (perfTarget ? ' of ' + perfTarget : '') + ' is: ' + timed.toFixed() + ' ms'; 9 | } 10 | 11 | assert.isOk(true, logMsg); 12 | }; 13 | -------------------------------------------------------------------------------- /benchmarks/runBenchmarks.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* eslint-env node, mocha */ 3 | 4 | process.chdir(__dirname); 5 | require('../tests/mockup/mockupForNode.js'); 6 | var Mocha = require('mocha'); 7 | 8 | var mocha = new Mocha({ 9 | ui: 'qunit', 10 | reporter: 'list' 11 | }); 12 | 13 | mocha.addFile('../builds/tests/benchmarks.js'); 14 | mocha.run(); 15 | -------------------------------------------------------------------------------- /examples/animate-lightcolor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Animate light color 6 | 7 | 8 | 9 | 10 | 11 | d 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | OSG.JS 31 | 32 | 33 |
34 | This sample demonstrate how animate light color with node::updatecallback. 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/animate-rotation/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Animate Rotation 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 |
40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/animate-transparency/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Animate Transparency 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | OSG.JS 31 | 32 |
42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/basic-transform/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Basic Transform 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 |
32 | This sample demonstrate how apply Transform on Geometry using MatrixTransform Node 33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/basic-transform/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var OSG = window.OSG; 4 | var osg = OSG.osg; 5 | var osgViewer = OSG.osgViewer; 6 | 7 | var onLoad = function() { 8 | // The 3D canvas. 9 | var canvas = document.getElementById('View'); 10 | // Here we create a MatrixTransform Node 11 | // that holds the transformation. 12 | var group = new osg.MatrixTransform(); 13 | group.setMatrix(osg.mat4.fromTranslation(osg.mat4.create(), osg.vec3.fromValues(-5, 10, -5))); 14 | var size = 5; 15 | // ground node is the geometry 16 | var ground = osg.createTexturedBoxGeometry(0, 0, 0, size, size, size); 17 | // We add geometry as child of the transform 18 | // and now it's transformed magically 19 | group.addChild(ground); 20 | group.getOrCreateStateSet().setAttributeAndModes(new osg.CullFace('DISABLE')); 21 | 22 | var mainNode = new osg.Node(); 23 | var lightnew = new osg.Light(); 24 | mainNode.light = lightnew; 25 | mainNode.addChild(group); 26 | 27 | // The viewer 28 | var viewer = new osgViewer.Viewer(canvas); 29 | viewer.init(); 30 | viewer.setSceneData(mainNode); 31 | viewer.setupManipulator(); 32 | viewer.run(); 33 | }; 34 | 35 | // Wait for it 36 | window.addEventListener('load', onLoad, true); 37 | -------------------------------------------------------------------------------- /examples/camera-gallery/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CameraSwitcher 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | OSG.JS 31 | 32 | 33 |
34 | This sample demonstrate how to change different view point using interpolation between them. 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/camera/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Camera 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 | OSG.JS 32 | 33 | 34 |
35 | Simple example to show usage of multiple camera for RTT 36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/camera/textures/sol_trauma_periph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/camera/textures/sol_trauma_periph.png -------------------------------------------------------------------------------- /examples/cubemotion/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/cubemotion/image.png -------------------------------------------------------------------------------- /examples/cubemotion/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cube Motion 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | OSG.JS 31 | 32 | 33 |
34 | Cube Motion is a simple example how to make some animation with UpdateCallback. 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/customshader/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Custom Shader 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | OSG.JS 29 | 30 |
31 | Custom shader and automatic ui bind 32 |
33 | 34 |
35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/dragndrop/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Drag And Drop 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 | OSG.JS 32 | 33 | 34 |
35 | Drag & Drop viewer 36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/files.js: -------------------------------------------------------------------------------- 1 | /* exported files */ 2 | // eslint-disable-next-line 3 | var files = { 4 | Examples: [ 5 | 'animation', 6 | 'camera', 7 | 'cubemotion', 8 | 'drawbuffers', 9 | 'frustum-culling', 10 | 'geometry', 11 | 'gizmo', 12 | 'lights', 13 | 'materials', 14 | 'morph', 15 | 'multipleviewers', 16 | 'pagedlod', 17 | 'pbr', 18 | 'performance', 19 | 'picking', 20 | 'postprocess', 21 | 'quad-texture', 22 | 'scene-debug', 23 | 'shader-generator', 24 | 'shadowmap', 25 | 'sound-3d', 26 | 'split-rendering-rtt', 27 | 'text2D', 28 | 'texture-video', 29 | 'webVR' 30 | ], 31 | 32 | Tutorials: [ 33 | 'multi-viewport-rtt', 34 | 'animate-lightcolor', 35 | 'animate-rotation', 36 | 'animate-transparency', 37 | 'basic-transform', 38 | 'customshader', 39 | 'dragndrop', 40 | 'findnode-visitor', 41 | 'load-model', 42 | 'multiplelights', 43 | 'screenshot', 44 | 'usercamera' 45 | ] 46 | }; 47 | -------------------------------------------------------------------------------- /examples/findnode-visitor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Find Node Visitor 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 | 32 |

a

33 |

b

34 |

c

35 | 36 |
37 | Find nodes by name 38 |
39 | 40 |
41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /examples/frustum-culling/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Frustum Computations example 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | OSG.JS 41 | 42 | 43 |
44 | Frustum Culling: Objects outside of Main camera will disappear from bottom right debug view, showing effectiveness of frustum culling real-time 45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/geometry/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Geometry 6 | 7 | 8 | 9 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 | 44 |
45 | 46 |
47 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/gizmo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gizmo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 | 32 |
33 | Demonstrate gizmo editing: click on model, select gizmo axis by clicking and moving while still mouse button pushed. 34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/hdr/textures/Alexs_Apartment/Alexs_Apt_2k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Alexs_Apartment/Alexs_Apt_2k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Alexs_Apartment/Alexs_Apt_2k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Alexs_Apartment/Alexs_Apt_2k.png -------------------------------------------------------------------------------- /examples/hdr/textures/Alexs_Apartment/Alexs_Apt_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Alexs_Apartment/Alexs_Apt_Env.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Alexs_Apartment/Alexs_Apt_Env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Alexs_Apartment/Alexs_Apt_Env.png -------------------------------------------------------------------------------- /examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_3k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_3k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_3k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_3k.png -------------------------------------------------------------------------------- /examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_Env.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_Env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Arches_E_PineTree/Arches_E_PineTree_Env.png -------------------------------------------------------------------------------- /examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_3k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_3k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_3k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_3k.png -------------------------------------------------------------------------------- /examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_Env.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_Env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/GrandCanyon_C_YumaPoint/GCanyon_C_YumaPoint_Env.png -------------------------------------------------------------------------------- /examples/hdr/textures/Milkyway/Milkyway_Light.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Milkyway/Milkyway_Light.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Milkyway/Milkyway_Light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Milkyway/Milkyway_Light.png -------------------------------------------------------------------------------- /examples/hdr/textures/Milkyway/Milkyway_small.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Milkyway/Milkyway_small.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Milkyway/Milkyway_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Milkyway/Milkyway_small.png -------------------------------------------------------------------------------- /examples/hdr/textures/PaperMill_Ruins_E/PaperMill_E_3k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/PaperMill_Ruins_E/PaperMill_E_3k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Tropical_Ruins/TropicalRuins_3k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Tropical_Ruins/TropicalRuins_3k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Walk_Of_Fame/Mans_Outside_2k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Walk_Of_Fame/Mans_Outside_2k.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Walk_Of_Fame/Mans_Outside_2k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Walk_Of_Fame/Mans_Outside_2k.png -------------------------------------------------------------------------------- /examples/hdr/textures/Walk_Of_Fame/Mans_Outside_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Walk_Of_Fame/Mans_Outside_Env.hdr -------------------------------------------------------------------------------- /examples/hdr/textures/Walk_Of_Fame/Mans_Outside_Env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/hdr/textures/Walk_Of_Fame/Mans_Outside_Env.png -------------------------------------------------------------------------------- /examples/lights/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Lights example 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | OSG.JS 41 | 42 | 43 |
44 | Use differents lights types in osgjs 45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/load-model/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Load Model 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 | 32 |
33 | Demonstrate how to load a osgjs model 34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/load-model/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var OSG = window.OSG; 4 | var osg = OSG.osg; 5 | var osgDB = OSG.osgDB; 6 | var osgViewer = OSG.osgViewer; 7 | 8 | var main = function() { 9 | // The 3D canvas. 10 | var canvas = document.getElementById('View'); 11 | var viewer; 12 | 13 | // The viewer 14 | viewer = new osgViewer.Viewer(canvas); 15 | viewer.init(); 16 | var rootNode = new osg.Node(); 17 | viewer.setSceneData(rootNode); 18 | viewer.setupManipulator(); 19 | viewer.run(); 20 | 21 | var modelURL = 'http://osgjs.org/examples/media/models/material-test/file.osgjs'; 22 | var request = osgDB.readNodeURL(modelURL); 23 | 24 | request 25 | .then(function(model) { 26 | var mt = new osg.MatrixTransform(); 27 | osg.mat4.rotateZ(mt.getMatrix(), mt.getMatrix(), -Math.PI); 28 | 29 | mt.addChild(model); 30 | 31 | rootNode.addChild(mt); 32 | viewer.getManipulator().computeHomePosition(); 33 | 34 | var loading = document.getElementById('loading'); 35 | document.body.removeChild(loading); 36 | }) 37 | .catch(function() { 38 | osg.warn('cant load ' + modelURL); 39 | }); 40 | }; 41 | 42 | window.addEventListener('load', main, true); 43 | -------------------------------------------------------------------------------- /examples/morph/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example Morphing 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | OSG.JS 41 | 42 | 43 |
44 | Example-MorphGeometry -- Press space bar 45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/multi-viewport-rtt/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Multi Camera RTT on the same texture 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 | 31 | OSG.JS 32 | 33 | 34 |
35 | Multi camera RTT on the same texture with Scissor and Viewport 36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/multiplelights/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Multiple Lights 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 | 32 |
33 | Array of Light & Changing light direction 34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/pagedlod/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PagedLod 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | OSG.JS 31 | 32 | 33 |
34 | Demonstrate the usage of PageLOD 35 |
36 |
37 |
38 |
39 | 46 |
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/pbr/README.md: -------------------------------------------------------------------------------- 1 | **Tools required** 2 | - envtools 3 | - rgbx 4 | -------------------------------------------------------------------------------- /examples/pbr/shaders/cubemapFragment.glsl: -------------------------------------------------------------------------------- 1 | uniform samplerCube uEnvironmentCube; 2 | 3 | uniform mat4 uEnvironmentTransform; 4 | uniform float uLod; 5 | uniform float uBrightness; 6 | uniform vec2 uEnvironmentLodRange; 7 | #ifdef CUBEMAP_LOD 8 | #extension GL_EXT_shader_texture_lod : enable 9 | #endif 10 | uniform vec2 uEnvironmentSize; 11 | 12 | varying vec3 vViewVertex; 13 | varying vec3 vViewNormal; 14 | varying vec2 vTexCoord0; 15 | varying vec3 vLocalVertex; 16 | 17 | #pragma include "cubemapSampler.glsl" 18 | #pragma include "colorSpace.glsl" 19 | 20 | mat3 getEnvironmentTransfrom( mat4 transform ) { 21 | vec3 x = vec3(transform[0][0], transform[1][0], transform[2][0]); 22 | vec3 y = vec3(transform[0][1], transform[1][1], transform[2][1]); 23 | vec3 z = vec3(transform[0][2], transform[1][2], transform[2][2]); 24 | mat3 m = mat3(x,y,z); 25 | return m; 26 | } 27 | 28 | void main() { 29 | vec3 direction = normalize( vViewNormal); 30 | //direction = normalize(vLocalVertex.xyz); 31 | direction = getEnvironmentTransfrom( uEnvironmentTransform ) * direction; 32 | #ifdef CUBEMAP_LOD 33 | vec3 color = uBrightness * textureCubeLodEXTFixed(uEnvironmentCube, direction, uLod ).rgb; 34 | #else 35 | vec3 color = uBrightness * textureCubeFixed( uEnvironmentCube, direction ).rgb; 36 | #endif 37 | //color = textureCube(uEnvironment, direction ).rgb; 38 | gl_FragColor = vec4( linearTosRGB(color, DefaultGamma ), 1.0); 39 | } 40 | -------------------------------------------------------------------------------- /examples/pbr/shaders/cubemapVertex.glsl: -------------------------------------------------------------------------------- 1 | attribute vec3 Vertex; 2 | attribute vec3 Normal; 3 | attribute vec2 TexCoord0; 4 | attribute vec4 Tangent; 5 | 6 | uniform mat4 uModelViewMatrix; 7 | uniform mat4 uModelMatrix; 8 | uniform mat4 uProjectionMatrix; 9 | uniform mat3 uModelViewNormalMatrix; 10 | 11 | varying vec3 vViewVertex; 12 | varying vec3 vViewNormal; 13 | varying vec4 vViewTangent; 14 | varying vec2 vTexCoord0; 15 | varying vec3 vLocalVertex; 16 | 17 | void main(void) { 18 | 19 | vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0)); 20 | vViewNormal = uModelViewNormalMatrix * Normal; 21 | vLocalVertex = Vertex; 22 | 23 | vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w); 24 | vTexCoord0 = TexCoord0; 25 | 26 | gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0); 27 | } 28 | -------------------------------------------------------------------------------- /examples/pbr/shaders/math.glsl: -------------------------------------------------------------------------------- 1 | 2 | #define PI 3.1415926535897932384626433832795 3 | #define PI_2 (2.0*3.1415926535897932384626433832795) 4 | #define INV_PI 1.0/PI 5 | #define INV_LOG2 1.4426950408889634073599246810019 6 | -------------------------------------------------------------------------------- /examples/pbr/shaders/panoramaVertex.glsl: -------------------------------------------------------------------------------- 1 | attribute vec3 Vertex; 2 | attribute vec3 Normal; 3 | attribute vec2 TexCoord0; 4 | attribute vec4 Tangent; 5 | 6 | uniform mat4 uModelViewMatrix; 7 | uniform mat4 uModelMatrix; 8 | uniform mat4 uProjectionMatrix; 9 | uniform mat3 uModelViewNormalMatrix; 10 | 11 | 12 | varying vec3 vViewVertex; 13 | varying vec3 vViewNormal; 14 | varying vec4 vViewTangent; 15 | varying vec2 vTexCoord0; 16 | 17 | 18 | void main(void) { 19 | 20 | vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0)); 21 | vViewNormal = uModelViewNormalMatrix * Normal; 22 | 23 | vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w); 24 | vTexCoord0 = TexCoord0; 25 | 26 | gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0); 27 | } 28 | -------------------------------------------------------------------------------- /examples/pbr/shaders/pbrReferenceVertex.glsl: -------------------------------------------------------------------------------- 1 | 2 | attribute vec3 Vertex; 3 | attribute vec3 Normal; 4 | attribute vec2 TexCoord0; 5 | attribute vec4 Tangent; 6 | attribute vec4 Color; 7 | uniform mat4 uModelViewMatrix; 8 | uniform mat4 uProjectionMatrix; 9 | uniform mat3 uModelViewNormalMatrix; 10 | 11 | varying vec3 vViewVertex; 12 | varying vec3 vViewNormal; 13 | varying vec4 vViewTangent; 14 | varying vec2 vTexCoord0; 15 | varying vec4 vVertexColor; 16 | 17 | void main(void) { 18 | 19 | vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0)); 20 | vViewNormal = uModelViewNormalMatrix * Normal; 21 | vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w); 22 | vTexCoord0 = TexCoord0; 23 | vVertexColor = Color; 24 | gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0); 25 | } 26 | -------------------------------------------------------------------------------- /examples/pbr/shaders/sphericalHarmonicsFragment.glsl: -------------------------------------------------------------------------------- 1 | 2 | varying vec3 vViewNormal; 3 | varying vec3 vLocalVertex; 4 | 5 | uniform vec3 uEnvironmentSphericalHarmonics[9]; 6 | uniform mat4 uEnvironmentTransform; 7 | 8 | 9 | #pragma include "colorSpace.glsl" 10 | #pragma include "sphericalHarmonics.glsl" 11 | 12 | 13 | mat3 getEnvironmentTransfrom( mat4 transform ) { 14 | vec3 x = vec3(transform[0][0], transform[1][0], transform[2][0]); 15 | vec3 y = vec3(transform[0][1], transform[1][1], transform[2][1]); 16 | vec3 z = vec3(transform[0][2], transform[1][2], transform[2][2]); 17 | mat3 m = mat3(x,y,z); 18 | return m; 19 | } 20 | 21 | void main() { 22 | 23 | mat3 environmentTransform = getEnvironmentTransfrom( uEnvironmentTransform ); 24 | vec3 n = normalize( vViewNormal ); 25 | n = environmentTransform * n; 26 | vec3 color = sphericalHarmonics( uEnvironmentSphericalHarmonics, n ); 27 | gl_FragColor = vec4( linearTosRGB(color, DefaultGamma), 1.0); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /examples/pbr/shaders/sphericalHarmonicsVertex.glsl: -------------------------------------------------------------------------------- 1 | attribute vec3 Vertex; 2 | attribute vec3 Normal; 3 | attribute vec2 TexCoord0; 4 | attribute vec4 Tangent; 5 | 6 | uniform mat4 uModelViewMatrix; 7 | uniform mat4 uProjectionMatrix; 8 | uniform mat3 uModelViewNormalMatrix; 9 | 10 | 11 | varying vec3 vViewVertex; 12 | varying vec3 vViewNormal; 13 | varying vec4 vViewTangent; 14 | varying vec2 vTexCoord0; 15 | varying vec3 vLocalVertex; 16 | 17 | 18 | void main(void) { 19 | 20 | vViewVertex = vec3(uModelViewMatrix * vec4(Vertex, 1.0)); 21 | vViewNormal = uModelViewNormalMatrix * Normal; 22 | vLocalVertex = Vertex; 23 | 24 | vViewTangent = vec4(uModelViewNormalMatrix * Tangent.xyz, Tangent.w); 25 | vTexCoord0 = TexCoord0; 26 | 27 | gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(Vertex,1.0); 28 | } 29 | -------------------------------------------------------------------------------- /examples/performance/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Performance 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 |
29 | 30 |
31 | 32 | 33 | 34 | OSG.JS 35 | 36 | 37 |
38 | Performance scene to stress test the framework with a lot of entities 39 |
40 | 41 |
42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/performance/textures/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/examples/performance/textures/texture.png -------------------------------------------------------------------------------- /examples/picking/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Picking 6 | 7 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 |
33 |
34 | 35 |
36 | 37 | 38 | 39 | OSG.JS 40 | 41 | 42 |
43 | Demonstrate picking with ray interesection 44 |
45 | 46 |
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/postprocess/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Postprocess 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | OSG.JS 30 | 31 | 32 |
33 | This example demonstrates the use of the ComposerPostProcess component to implement 34 | different postprocess effects 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/blackAndWhite.glsl: -------------------------------------------------------------------------------- 1 | float luminance(const in vec3 color) { 2 | return dot(color, vec3(0.299, 0.587, 0.114)); 3 | } 4 | 5 | vec4 blackAndWhite(const in vec4 color) { 6 | return vec4(vec3(luminance(color.rgb)), color.a); 7 | } 8 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/blackAndWhite.json: -------------------------------------------------------------------------------- 1 | { 2 | "passes": [ 3 | { 4 | "func": "blackAndWhite", 5 | "textures": "%last", 6 | "out": { "name": "%next" }, 7 | "collapsible": true 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/colorBalance.glsl: -------------------------------------------------------------------------------- 1 | #pragma include "sampleLUT.glsl" 2 | 3 | uniform sampler2D TextureLUT; 4 | 5 | vec4 colorBalance() { 6 | vec3 color = TEXTURE_2D_TextureInput(gTexCoord).rgb; 7 | 8 | if(gl_FragCoord.x < 256.0 && gl_FragCoord.y < 16.0) { 9 | return texture2D(TextureLUT, vec2(gl_FragCoord.x / 256.0, gl_FragCoord.y / 16.0)); 10 | } 11 | 12 | return vec4(sampleLUT(color.rgb, TextureLUT), 1.0); 13 | } 14 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/colorBalance.json: -------------------------------------------------------------------------------- 1 | { 2 | "passes": [ 3 | { 4 | "func": "colorBalanceLUT", 5 | "textures": [], 6 | "out": { "name": "TextureLUT", "divisor": -1.0, "width": 256, "height": 16 } 7 | }, 8 | { 9 | "func": "colorBalance", 10 | "textures": ["%last", { "name": "TextureLUT", "filter": "linear" }], 11 | "out": { "name": "%next" } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/colorCorrection.glsl: -------------------------------------------------------------------------------- 1 | #pragma include "sampleLUT.glsl" 2 | 3 | uniform sampler2D TextureLut; 4 | 5 | vec4 colorCorrection(const in vec4 color) { 6 | return vec4(sampleLUT(color.rgb, TextureLut), 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/colorCorrection.json: -------------------------------------------------------------------------------- 1 | { 2 | "passes": [ 3 | { 4 | "func": "colorCorrection", 5 | "textures": ["%last", "TextureLut"], 6 | "out": { "name": "%next" }, 7 | "collapsible": true 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/postprocess/shaders/sampleLUT.glsl: -------------------------------------------------------------------------------- 1 | vec3 getLUTCoords3d() { 2 | vec2 texCoords = floor(gl_FragCoord.xy); 3 | 4 | vec3 coords3d; 5 | coords3d.x = mod(texCoords.x, 16.0); 6 | coords3d.y = texCoords.y; 7 | coords3d.z = floor(texCoords.x / 16.0); 8 | 9 | coords3d /= 15.0; 10 | coords3d.y = 1.0 - coords3d.y; 11 | return coords3d; 12 | } 13 | 14 | //https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/PostProcessCommon.ush#L187 15 | vec3 sampleLUT(const in vec3 color, const in sampler2D lut) { 16 | vec3 coords = vec3(color.r, 1.0 - color.g, color.b) * 15.0 / 16.0 + 0.5 / 16.0; 17 | 18 | float nearestZ = floor(coords.z * 16.0 - 0.5); 19 | 20 | float u = (coords.x + nearestZ) / 16.0; 21 | float v = coords.y; 22 | 23 | vec3 sample0 = texture2D(lut, vec2(u, v)).rgb; 24 | vec3 sample1 = texture2D(lut, vec2(u + 1.0 / 16.0, v)).rgb; 25 | 26 | float mixFactor = coords.z * 16.0 - 0.5 - nearestZ; 27 | return mix(sample0, sample1, mixFactor); 28 | } -------------------------------------------------------------------------------- /examples/postprocess/shaders/vignette.glsl: -------------------------------------------------------------------------------- 1 | uniform vec2 uLensRadius; 2 | 3 | vec4 vignette(const in vec4 color) { 4 | float dist = distance(gTexCoord, vec2(0.5)); 5 | 6 | return vec4(color * smoothstep(uLensRadius.x, uLensRadius.y, dist)); 7 | } -------------------------------------------------------------------------------- /examples/postprocess/shaders/vignette.json: -------------------------------------------------------------------------------- 1 | { 2 | "passes": [ 3 | { 4 | "func": "vignette", 5 | "textures": "%last", 6 | "out": { "name": "%next" }, 7 | "collapsible": true 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/quad-texture/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Textured quad example 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | 32 | 33 |
34 | 35 |
36 | 37 | 38 | 39 | OSG.JS 40 | 41 | 42 |
43 | Very basic sample to demonstrate how to make a textured quad 44 |
45 | 46 |
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /examples/scene-debug/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Scene debug 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 |
27 | 28 |
29 | 30 | 31 | 32 | OSG.JS 33 | 34 | 35 |
36 | Scene debug is a graph visualizator of the scene. 37 |
38 | 39 |
40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/screenshot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Load Model 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 |
25 | 26 |
27 |
28 | 29 | 30 | 31 | OSG.JS 32 | 33 | click to download last screenshot 34 |
35 | Demonstrate how make a Screenshot Each 5 sec 36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/shader-generator/negatif.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var osg = window.OSG.osg; 5 | 6 | var NegatifAttribute = function() { 7 | osg.StateAttribute.call(this); 8 | this._attributeEnable = false; 9 | }; 10 | 11 | window.NegatifAttribute = NegatifAttribute; 12 | 13 | osg.createPrototypeStateAttribute( 14 | NegatifAttribute, 15 | osg.objectInherit(osg.StateAttribute.prototype, { 16 | attributeType: 'Negatif', 17 | 18 | cloneType: function() { 19 | return new NegatifAttribute(); 20 | }, 21 | 22 | // uniforms list are per ClassType 23 | getOrCreateUniforms: function() { 24 | var obj = NegatifAttribute; 25 | if (obj.uniforms) return obj.uniforms; 26 | 27 | obj.uniforms = { 28 | enable: osg.Uniform.createInt1(0, 'negatifEnable') 29 | }; 30 | 31 | return obj.uniforms; 32 | }, 33 | 34 | setAttributeEnable: function(state) { 35 | this._attributeEnable = state; 36 | }, 37 | 38 | getAttributeEnable: function() { 39 | return this._attributeEnable; 40 | }, 41 | 42 | apply: function() { 43 | var uniforms = this.getOrCreateUniforms(); 44 | var value = this._attributeEnable ? 1 : 0; 45 | uniforms.enable.setFloat(value); 46 | } 47 | }), 48 | 'osg', 49 | 'Negatif' 50 | ); 51 | })(); 52 | -------------------------------------------------------------------------------- /examples/shader-generator/ramp.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var osg = window.OSG.osg; 5 | 6 | var RampAttribute = function() { 7 | osg.StateAttribute.call(this); 8 | this._attributeEnable = false; 9 | }; 10 | 11 | window.RampAttribute = RampAttribute; 12 | 13 | osg.createPrototypeStateAttribute( 14 | RampAttribute, 15 | osg.objectInherit(osg.StateAttribute.prototype, { 16 | attributeType: 'Ramp', 17 | 18 | cloneType: function() { 19 | return new RampAttribute(); 20 | }, 21 | 22 | setAttributeEnable: function(state) { 23 | this._attributeEnable = state; 24 | }, 25 | 26 | getAttributeEnable: function() { 27 | return this._attributeEnable; 28 | }, 29 | 30 | // getHash is used to know if an StateAttribute changed 31 | // if yes it will trigger a shader rebuild. You can for example 32 | // trigger a change if we enable or not the attribute. It's really 33 | // up to how you want to handle your shaders 34 | // if you dont want to trigger rebuild of shader then instead you an use a 35 | // uniform and keep always the same hash 36 | getHash: function() { 37 | return this.getType() + this._attributeEnable.toString(); 38 | } 39 | }), 40 | 'osg', 41 | 'Ramp' 42 | ); 43 | })(); 44 | -------------------------------------------------------------------------------- /examples/shader-generator/shaders/custom.glsl: -------------------------------------------------------------------------------- 1 | #pragma DECLARE_FUNCTION 2 | void ramp( const in vec3 colorInput, out vec3 colorOutput ) { 3 | 4 | // ramp 0.2 5 | if ( length(colorInput) < 0.2 ) { 6 | colorOutput = vec3( 0.1 ); 7 | return; 8 | } 9 | 10 | if ( length(colorInput) < 0.5 ) { 11 | colorOutput = vec3( 0.3 ); 12 | return; 13 | } 14 | 15 | if ( length(colorInput) < 0.9 ) { 16 | colorOutput = vec3( 0.7 ); 17 | return; 18 | } else { 19 | colorOutput = vec3(1.0); 20 | } 21 | 22 | } 23 | 24 | #pragma DECLARE_FUNCTION 25 | void negatif( const in int enable, const in vec3 colorInput, out vec3 colorOutput ) { 26 | 27 | if ( enable == 1 ) 28 | colorOutput = vec3(1.0) - colorInput; 29 | else 30 | colorOutput = colorInput; 31 | } 32 | -------------------------------------------------------------------------------- /examples/shadowmap/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Advanded Shadow Map 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 |
29 | 30 |
31 | 32 | 33 | 34 | OSG.JS 35 | 36 | 37 |
38 | ShadowMap: Wikipedia page 39 |
40 | 41 |
42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/split-rendering-rtt/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example Title 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | OSG.JS 41 | 42 | 43 |
44 | Proof of concept to split rendering that depends on RenderBin num 45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/templates/main.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | // various osg shortcuts 5 | var OSG = window.OSG; 6 | var osg = OSG.osg; 7 | var ExampleOSGJS = window.ExampleOSGJS; 8 | 9 | // inherits for the ExampleOSGJS prototype 10 | var Example = function() { 11 | // can be overriden with url parm ?&scale=1 12 | this._config = { 13 | scale: 0.1 14 | }; 15 | }; 16 | 17 | Example.prototype = osg.objectInherit(ExampleOSGJS.prototype, { 18 | initDatGUI: function() { 19 | // config to let data gui change the scale 20 | this._gui = new window.dat.GUI(); 21 | // use of scale from config default value or url parm ?&scale=1 22 | var controller = this._gui.add(this._config, 'scale', 0.1, 2.0); 23 | var self = this; 24 | controller.onChange(function(value) { 25 | // change the matrix 26 | osg.mat4.fromScaling(self._model.getMatrix(), [value, value, value]); 27 | self._model.dirtyBound(); 28 | }); 29 | } 30 | }); 31 | 32 | window.addEventListener( 33 | 'load', 34 | function() { 35 | var example = new Example(); 36 | example.run(); 37 | }, 38 | true 39 | ); 40 | })(); 41 | -------------------------------------------------------------------------------- /examples/text2D/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Text 2D 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | 27 | 28 |
29 |
30 | 31 | 32 |
33 | 34 |
35 | 36 | 37 | 38 | OSG.JS 39 | 40 |
41 | Text 2D over webGL canvas using a Canvas2D and RTT 42 |
43 |
44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /examples/usercamera/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | User Camera 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | OSG.JS 29 | 30 | 31 |
32 | Camera Rotation and matrix from user source (here device orientation) 33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /examples/webVR/ic_cardboard_white_24dp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/webVR/ic_fullscreen_exit_white_24dp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sources/OSG.js: -------------------------------------------------------------------------------- 1 | import 'osg/polyfill'; 2 | import osgNameSpace from 'osgNameSpace'; 3 | import osg from 'osg/osg'; 4 | import osgAnimation from 'osgAnimation/osgAnimation'; 5 | import osgDB from 'osgDB/osgDB'; 6 | import osgGA from 'osgGA/osgGA'; 7 | import osgUtil from 'osgUtil/osgUtil'; 8 | import osgViewer from 'osgViewer/osgViewer'; 9 | import osgShader from 'osgShader/osgShader'; 10 | import osgShadow from 'osgShadow/osgShadow'; 11 | import osgStats from 'osgStats/osgStats'; 12 | import osgText from 'osgText/osgText'; 13 | import osgWrappers from 'osgWrappers/osgWrappers'; 14 | import osgPlugins from 'osgPlugins/osgPlugins'; 15 | 16 | var OSG = osgNameSpace; 17 | 18 | OSG.osg = osg; 19 | OSG.osgAnimation = osgAnimation; 20 | OSG.osgDB = osgDB; 21 | OSG.osgGA = osgGA; 22 | OSG.osgUtil = osgUtil; 23 | OSG.osgViewer = osgViewer; 24 | OSG.osgShader = osgShader; 25 | OSG.osgShadow = osgShadow; 26 | OSG.osgStats = osgStats; 27 | OSG.osgText = osgText; 28 | OSG.osgWrappers = osgWrappers; 29 | OSG.osgPlugins = osgPlugins; 30 | OSG.InputGroups = osgViewer.InputGroups; 31 | 32 | // for backward compatibility 33 | OSG.globalify = function() { 34 | window.osg = OSG.osg; 35 | window.osgAnimation = OSG.osgAnimation; 36 | window.osgDB = OSG.osgDB; 37 | window.osgGA = OSG.osgGA; 38 | window.osgUtil = OSG.osgUtil; 39 | window.osgViewer = OSG.osgViewer; 40 | window.osgShader = OSG.osgShader; 41 | window.osgShadow = OSG.osgShadow; 42 | window.osgStats = OSG.osgStats; 43 | window.osgText = OSG.osgText; 44 | window.osgWrappers = OSG.osgWrappers; 45 | window.osgPlugins = OSG.osgPlugins; 46 | window.InputGroups = OSG.InputGroups; 47 | }; 48 | 49 | export { 50 | osg, 51 | osgAnimation, 52 | osgDB, 53 | osgGA, 54 | osgUtil, 55 | osgViewer, 56 | osgShader, 57 | osgShadow, 58 | osgStats, 59 | osgText, 60 | osgWrappers, 61 | osgPlugins 62 | }; 63 | 64 | export default OSG; 65 | -------------------------------------------------------------------------------- /sources/config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ArrayType: Float64Array 3 | }; 4 | -------------------------------------------------------------------------------- /sources/osg/BillboardAttribute.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | var BillboardAttribute = function() { 5 | StateAttribute.call(this); 6 | this._attributeEnable = false; 7 | }; 8 | 9 | utils.createPrototypeStateAttribute( 10 | BillboardAttribute, 11 | utils.objectInherit(StateAttribute.prototype, { 12 | attributeType: 'Billboard', 13 | 14 | cloneType: function() { 15 | return new BillboardAttribute(); 16 | }, 17 | 18 | setEnabled: function(state) { 19 | this._attributeEnable = state; 20 | }, 21 | 22 | isEnabled: function() { 23 | return this._attributeEnable; 24 | }, 25 | 26 | apply: function() {} 27 | }), 28 | 'osg', 29 | 'Billboard' 30 | ); 31 | 32 | export default BillboardAttribute; 33 | -------------------------------------------------------------------------------- /sources/osg/BlendColor.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | import { vec4 } from 'osg/glMatrix'; 4 | 5 | /** 6 | * Manage BlendColor attribute 7 | * @class 8 | * @memberOf osg 9 | * @extends StateAttribute 10 | */ 11 | var BlendColor = function(color) { 12 | StateAttribute.call(this); 13 | this._constantColor = vec4.create(); 14 | vec4.set(this._constantColor, 1.0, 1.0, 1.0, 1.0); 15 | if (color !== undefined) { 16 | this.setConstantColor(color); 17 | } 18 | }; 19 | 20 | /** 21 | * @lends BlendColor.prototype 22 | */ 23 | utils.createPrototypeStateAttribute( 24 | BlendColor, 25 | utils.objectInherit(StateAttribute.prototype, { 26 | attributeType: 'BlendColor', 27 | cloneType: function() { 28 | return new BlendColor(); 29 | }, 30 | 31 | /** 32 | * 33 | * @param {} color 34 | */ 35 | setConstantColor: function(color) { 36 | vec4.copy(this._constantColor, color); 37 | }, 38 | getConstantColor: function() { 39 | return this._constantColor; 40 | }, 41 | apply: function(state) { 42 | var gl = state.getGraphicContext(); 43 | gl.blendColor( 44 | this._constantColor[0], 45 | this._constantColor[1], 46 | this._constantColor[2], 47 | this._constantColor[3] 48 | ); 49 | } 50 | }), 51 | 'osg', 52 | 'BlendColor' 53 | ); 54 | 55 | export default BlendColor; 56 | -------------------------------------------------------------------------------- /sources/osg/BufferArrayProxy.js: -------------------------------------------------------------------------------- 1 | import BufferArray from 'osg/BufferArray'; 2 | 3 | var BufferArrayProxy = function(bufferArray) { 4 | this._initialBufferArray = undefined; 5 | this._bufferArray = undefined; 6 | if (bufferArray) { 7 | this.setBufferArray(bufferArray); 8 | this.setInitialBufferArray(bufferArray); 9 | } 10 | }; 11 | 12 | var prototype = { 13 | setInitialBufferArray: function(bufferArray) { 14 | this._initialBufferArray = bufferArray; 15 | }, 16 | getInitialBufferArray: function() { 17 | return this._initialBufferArray; 18 | }, 19 | setBufferArray: function(bufferArray) { 20 | this._bufferArray = bufferArray.getBufferArray ? bufferArray.getBufferArray() : bufferArray; 21 | }, 22 | getBufferArray: function() { 23 | return this._bufferArray; 24 | } 25 | }; 26 | 27 | // adds original method of BufferArray prototype for the proxy for convenient usage 28 | var makeFunc = function(func) { 29 | return function() { 30 | return func.apply(this._bufferArray, arguments); 31 | }; 32 | }; 33 | 34 | for (var methodName in BufferArray.prototype) { 35 | prototype[methodName] = makeFunc(BufferArray.prototype[methodName]); 36 | } 37 | 38 | BufferArrayProxy.prototype = prototype; 39 | export default BufferArrayProxy; 40 | -------------------------------------------------------------------------------- /sources/osg/ColorMask.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | var ColorMask = function(red, green, blue, alpha) { 5 | StateAttribute.call(this); 6 | this._red = true; 7 | this._green = true; 8 | this._blue = true; 9 | this._alpha = true; 10 | 11 | if (red !== undefined && green !== undefined && blue !== undefined) 12 | this.setMask(red, green, blue, alpha); 13 | }; 14 | 15 | utils.createPrototypeStateAttribute( 16 | ColorMask, 17 | utils.objectInherit(StateAttribute.prototype, { 18 | attributeType: 'ColorMask', 19 | cloneType: function() { 20 | return new ColorMask(); 21 | }, 22 | setMask: function(red, green, blue, alpha) { 23 | this._red = !!red; 24 | this._green = !!green; 25 | this._blue = !!blue; 26 | this._alpha = !!alpha; 27 | }, 28 | apply: function(state) { 29 | state.applyColorMask(this); 30 | } 31 | }), 32 | 'osg', 33 | 'ColorMask' 34 | ); 35 | 36 | export default ColorMask; 37 | -------------------------------------------------------------------------------- /sources/osg/CullFace.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | /** 5 | * Manage CullFace attribute 6 | * @class CullFace 7 | */ 8 | var CullFace = function(mode) { 9 | StateAttribute.call(this); 10 | this.setMode(mode !== undefined ? mode : CullFace.BACK); 11 | }; 12 | 13 | CullFace.DISABLE = 0x0; 14 | CullFace.FRONT = 0x0404; 15 | CullFace.BACK = 0x0405; 16 | CullFace.FRONT_AND_BACK = 0x0408; 17 | 18 | /** @lends CullFace.prototype */ 19 | utils.createPrototypeStateAttribute( 20 | CullFace, 21 | utils.objectInherit(StateAttribute.prototype, { 22 | attributeType: 'CullFace', 23 | 24 | cloneType: function() { 25 | return new CullFace(); 26 | }, 27 | 28 | setMode: function(mode) { 29 | var value = mode; 30 | if (typeof value === 'string') value = CullFace[value]; 31 | this._mode = value; 32 | }, 33 | 34 | getMode: function() { 35 | return this._mode; 36 | }, 37 | 38 | apply: function(state) { 39 | state.applyCullFace(this); 40 | } 41 | }), 42 | 'osg', 43 | 'CullFace' 44 | ); 45 | 46 | export default CullFace; 47 | -------------------------------------------------------------------------------- /sources/osg/Depth.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | var Depth = function(func, near, far, writeMask) { 5 | StateAttribute.call(this); 6 | 7 | this._func = Depth.LESS; 8 | this._near = 0.0; 9 | this._far = 1.0; 10 | this._writeMask = true; 11 | 12 | if (func !== undefined) { 13 | if (typeof func === 'string') { 14 | this._func = Depth[func]; 15 | } else { 16 | this._func = func; 17 | } 18 | } 19 | if (near !== undefined) { 20 | this._near = near; 21 | } 22 | if (far !== undefined) { 23 | this._far = far; 24 | } 25 | if (writeMask !== undefined) { 26 | this._writeMask = writeMask; 27 | } 28 | }; 29 | 30 | Depth.DISABLE = 0x0000; 31 | Depth.NEVER = 0x0200; 32 | Depth.LESS = 0x0201; 33 | Depth.EQUAL = 0x0202; 34 | Depth.LEQUAL = 0x0203; 35 | Depth.GREATER = 0x0204; 36 | Depth.NOTEQUAL = 0x0205; 37 | Depth.GEQUAL = 0x0206; 38 | Depth.ALWAYS = 0x0207; 39 | 40 | utils.createPrototypeStateAttribute( 41 | Depth, 42 | utils.objectInherit(StateAttribute.prototype, { 43 | attributeType: 'Depth', 44 | cloneType: function() { 45 | return new Depth(); 46 | }, 47 | setRange: function(near, far) { 48 | this._near = near; 49 | this._far = far; 50 | }, 51 | setWriteMask: function(mask) { 52 | this._writeMask = mask; 53 | }, 54 | getWriteMask: function() { 55 | return this._writeMask; 56 | }, 57 | getFunc: function() { 58 | return this._func; 59 | }, 60 | apply: function(state) { 61 | state.applyDepth(this); 62 | } 63 | }), 64 | 'osg', 65 | 'Depth' 66 | ); 67 | 68 | export default Depth; 69 | -------------------------------------------------------------------------------- /sources/osg/DrawArrayLengths.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DrawArrayLengths manage rendering primitives 3 | * @class DrawArrayLengths 4 | */ 5 | var DrawArrayLengths = function(mode, first, array) { 6 | this._mode = mode; 7 | this._first = first; 8 | this._arrayLengths = array.slice(0); 9 | }; 10 | 11 | /** @lends DrawArrayLengths.prototype */ 12 | DrawArrayLengths.prototype = { 13 | draw: function(state) { 14 | var gl = state.getGraphicContext(); 15 | var mode = this._mode; 16 | var first = this._first; 17 | var array = this._arrayLengths; 18 | for (var i = 0, l = array.length; i < l; i++) { 19 | var count = array[i]; 20 | gl.drawArrays(mode, first, count); 21 | first += count; 22 | } 23 | }, 24 | getMode: function() { 25 | return this._mode; 26 | }, 27 | getNumIndices: function() { 28 | var count = 0; 29 | var array = this._arrayLengths; 30 | for (var i = 0, l = array.length; i < l; i++) { 31 | count += array[i]; 32 | } 33 | return count; 34 | }, 35 | getCount: function() { 36 | return this.getNumIndices(); 37 | }, 38 | getArrayLengths: function() { 39 | return this._arrayLengths; 40 | }, 41 | getFirst: function() { 42 | return this._first; 43 | }, 44 | setFirst: function(first) { 45 | this._first = first; 46 | } 47 | }; 48 | 49 | export default DrawArrayLengths; 50 | -------------------------------------------------------------------------------- /sources/osg/DrawArrays.js: -------------------------------------------------------------------------------- 1 | import primitiveSet from 'osg/primitiveSet'; 2 | 3 | /** 4 | * DrawArrays manage rendering primitives 5 | * @class DrawArrays 6 | */ 7 | var DrawArrays = function(mode, first, count) { 8 | this.mode = mode; 9 | if (mode !== undefined) { 10 | if (typeof mode === 'string') { 11 | mode = primitiveSet[mode]; 12 | } 13 | this.mode = mode; 14 | } 15 | this.first = first; 16 | this.count = count; 17 | }; 18 | 19 | /** @lends DrawArrays.prototype */ 20 | DrawArrays.prototype = { 21 | draw: function(state) { 22 | if (this.count === 0) return; 23 | var gl = state.getGraphicContext(); 24 | gl.drawArrays(this.mode, this.first, this.count); 25 | }, 26 | getMode: function() { 27 | return this.mode; 28 | }, 29 | setCount: function(count) { 30 | this.count = count; 31 | }, 32 | getCount: function() { 33 | return this.count; 34 | }, 35 | setFirst: function(first) { 36 | this.first = first; 37 | }, 38 | getFirst: function() { 39 | return this.first; 40 | }, 41 | getNumIndices: function() { 42 | return this.count; 43 | }, 44 | index: function(i) { 45 | return this.first + i; 46 | } 47 | }; 48 | 49 | export default DrawArrays; 50 | -------------------------------------------------------------------------------- /sources/osg/FrameStamp.js: -------------------------------------------------------------------------------- 1 | var FrameStamp = function() { 2 | this._frame = 0; 3 | this._startSimulation = 0.0; 4 | this._currentSimulation = 0.0; 5 | this._deltaTime = 0.0; // last time elapsed since the next traversal 6 | }; 7 | 8 | FrameStamp.prototype = { 9 | setReferenceTime: function(s) { 10 | this._startSimulation = s; 11 | }, 12 | getReferenceTime: function() { 13 | return this._startSimulation; 14 | }, 15 | setSimulationTime: function(s) { 16 | this._currentSimulation = s; 17 | }, 18 | getSimulationTime: function() { 19 | return this._currentSimulation; 20 | }, 21 | setDeltaTime: function(d) { 22 | this._deltaTime = d; 23 | }, 24 | getDeltaTime: function() { 25 | return this._deltaTime; 26 | }, 27 | setFrameNumber: function(n) { 28 | this._frame = n; 29 | }, 30 | getFrameNumber: function() { 31 | return this._frame; 32 | } 33 | }; 34 | 35 | export default FrameStamp; 36 | -------------------------------------------------------------------------------- /sources/osg/KdTreeBuilder.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import NodeVisitor from 'osg/NodeVisitor'; 3 | import KdTree from 'osg/KdTree'; 4 | 5 | var KdTreeBuilder = function(options) { 6 | NodeVisitor.call(this); 7 | this._buildOptions = { 8 | _numVerticesProcessed: 0, 9 | _targetNumTrianglesPerLeaf: 50, 10 | _maxNumLevels: 20 11 | }; 12 | 13 | if (!options) return; 14 | 15 | // merge options 16 | var perLeaf = options._targetNumTrianglesPerLeaf; 17 | var maxLevel = options._maxNumLevels; 18 | 19 | if (perLeaf !== undefined) this._buildOptions._targetNumTrianglesPerLeaf = perLeaf; 20 | if (maxLevel !== undefined) this._buildOptions._maxNumLevels = maxLevel; 21 | }; 22 | 23 | utils.createPrototypeObject( 24 | KdTreeBuilder, 25 | utils.objectInherit(NodeVisitor.prototype, { 26 | apply: function(node) { 27 | if (node.getShape) { 28 | var shape = node.getShape(); 29 | // we test if the kdTree is already built and if we can build it (null means we skip it) 30 | if (shape === undefined) { 31 | var kdTree = new KdTree(); 32 | if (kdTree.build(this._buildOptions, node)) { 33 | node.setShape(kdTree); 34 | } 35 | } 36 | } 37 | this.traverse(node); 38 | } 39 | }), 40 | 'osg', 41 | 'KdTreeBuilder' 42 | ); 43 | 44 | export default KdTreeBuilder; 45 | -------------------------------------------------------------------------------- /sources/osg/LightSource.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Node from 'osg/Node'; 3 | import TransformEnums from 'osg/transformEnums'; 4 | import { vec3 } from 'osg/glMatrix'; 5 | 6 | /** 7 | * LightSource is a positioned node to use with StateAttribute Light 8 | * @class LightSource 9 | */ 10 | var LightSource = function() { 11 | Node.call(this); 12 | this.setCullingActive(false); 13 | this._light = undefined; 14 | this._referenceFrame = TransformEnums.RELATIVE_RF; 15 | }; 16 | 17 | /** @lends LightSource.prototype */ 18 | utils.createPrototypeNode( 19 | LightSource, 20 | utils.objectInherit(Node.prototype, { 21 | getLight: function() { 22 | return this._light; 23 | }, 24 | setLight: function(light) { 25 | this._light = light; 26 | }, 27 | setReferenceFrame: function(value) { 28 | this._referenceFrame = value; 29 | }, 30 | getReferenceFrame: function() { 31 | return this._referenceFrame; 32 | }, 33 | computeBoundingSphere: (function() { 34 | var tmp = vec3.create(); 35 | 36 | return function(bsphere) { 37 | Node.prototype.computeBoundingSphere.call(this, bsphere); 38 | 39 | if ( 40 | this._light !== undefined && 41 | this._referenceFrame === TransformEnums.RELATIVE_RF 42 | ) { 43 | var position = this._light.getPosition(); 44 | 45 | if (position[3] !== 0.0) { 46 | bsphere.expandByVec3(vec3.scale(tmp, position, 1.0 / position[3])); 47 | } 48 | } 49 | 50 | return bsphere; 51 | }; 52 | })() 53 | }), 54 | 'osg', 55 | 'LightSource' 56 | ); 57 | 58 | export default LightSource; 59 | -------------------------------------------------------------------------------- /sources/osg/LineWidth.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | var LineWidth = function(lineWidth) { 5 | StateAttribute.call(this); 6 | this.lineWidth = 1.0; 7 | if (lineWidth !== undefined) { 8 | this.lineWidth = lineWidth; 9 | } 10 | }; 11 | utils.createPrototypeStateAttribute( 12 | LineWidth, 13 | utils.objectInherit(StateAttribute.prototype, { 14 | attributeType: 'LineWidth', 15 | cloneType: function() { 16 | return new LineWidth(); 17 | }, 18 | apply: function(state) { 19 | state.getGraphicContext().lineWidth(this.lineWidth); 20 | } 21 | }), 22 | 'osg', 23 | 'LineWidth' 24 | ); 25 | 26 | export default LineWidth; 27 | -------------------------------------------------------------------------------- /sources/osg/MatrixTransform.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import { mat4 } from 'osg/glMatrix'; 3 | import Transform from 'osg/Transform'; 4 | import TransformEnums from 'osg/transformEnums'; 5 | 6 | /** 7 | * MatrixTransform is a Transform Node that can be customized with user matrix 8 | * @class MatrixTransform 9 | */ 10 | var MatrixTransform = function() { 11 | Transform.call(this); 12 | this.matrix = mat4.create(); 13 | }; 14 | 15 | /** @lends MatrixTransform.prototype */ 16 | utils.createPrototypeNode( 17 | MatrixTransform, 18 | utils.objectInherit(Transform.prototype, { 19 | getMatrix: function() { 20 | return this.matrix; 21 | }, 22 | 23 | setMatrix: function(m) { 24 | this.matrix = m; 25 | this.dirtyBound(); 26 | }, 27 | 28 | // local to "local world" (not Global World) 29 | computeLocalToWorldMatrix: function(matrix /*, nodeVisitor */) { 30 | if (this.referenceFrame === TransformEnums.RELATIVE_RF) { 31 | mat4.mul(matrix, matrix, this.matrix); 32 | } else { 33 | mat4.copy(matrix, this.matrix); 34 | } 35 | return true; 36 | }, 37 | 38 | computeWorldToLocalMatrix: (function() { 39 | var minverse = mat4.create(); 40 | return function(matrix /*, nodeVisitor */) { 41 | mat4.invert(minverse, this.matrix); 42 | if (this.referenceFrame === TransformEnums.RELATIVE_RF) { 43 | mat4.mul(matrix, minverse, matrix); 44 | } else { 45 | // absolute 46 | mat4.copy(matrix, minverse); 47 | } 48 | return true; 49 | }; 50 | })() 51 | }), 52 | 'osg', 53 | 'MatrixTransform' 54 | ); 55 | 56 | export default MatrixTransform; 57 | -------------------------------------------------------------------------------- /sources/osg/Object.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | 3 | /** 4 | * Object class 5 | * @class Object 6 | */ 7 | var OSGObject = function() { 8 | this._name = undefined; 9 | this._userdata = undefined; 10 | this._instanceID = OSGObject.getInstanceID(); 11 | }; 12 | 13 | /** @lends Object.prototype */ 14 | utils.createPrototypeObject( 15 | OSGObject, 16 | { 17 | // this method works only if constructor is set correctly 18 | // see issue https://github.com/cedricpinson/osgjs/issues/494 19 | cloneType: function() { 20 | var Constructor = this.constructor; 21 | return new Constructor(); 22 | }, 23 | 24 | getInstanceID: function() { 25 | return this._instanceID; 26 | }, 27 | 28 | setName: function(name) { 29 | this._name = name; 30 | }, 31 | 32 | getName: function() { 33 | return this._name; 34 | }, 35 | 36 | setUserData: function(data) { 37 | this._userdata = data; 38 | }, 39 | 40 | getUserData: function() { 41 | return this._userdata; 42 | } 43 | }, 44 | 'osg', 45 | 'Object' 46 | ); 47 | 48 | // get an instanceID for each object 49 | var instanceID = 0; 50 | OSGObject.getInstanceID = function() { 51 | instanceID += 1; 52 | return instanceID; 53 | }; 54 | 55 | export default OSGObject; 56 | -------------------------------------------------------------------------------- /sources/osg/PooledArray.js: -------------------------------------------------------------------------------- 1 | var PooledArray = function() { 2 | this._pool = []; 3 | this._length = 0; 4 | }; 5 | 6 | PooledArray.prototype = { 7 | clean: function() { 8 | this._length = 0; 9 | this._pool.length = 0; 10 | }, 11 | reset: function() { 12 | this._length = 0; 13 | }, 14 | getLength: function() { 15 | return this._length; 16 | }, 17 | getArray: function() { 18 | return this._pool; 19 | }, 20 | back: function() { 21 | return this._pool[this._length - 1]; 22 | }, 23 | pop: function() { 24 | this._length--; 25 | return this._pool[this._length]; 26 | }, 27 | push: function(value) { 28 | if (this._length === this._pool.length) { 29 | this._pool.push(value); 30 | } else { 31 | this._pool[this._length] = value; 32 | } 33 | this._length++; 34 | }, 35 | forEach: function(func) { 36 | for (var i = 0; i < this._length; i++) func(this._pool[i]); 37 | } 38 | }; 39 | 40 | export default PooledArray; 41 | -------------------------------------------------------------------------------- /sources/osg/PooledMap.js: -------------------------------------------------------------------------------- 1 | import PooledArray from 'osg/PooledArray'; 2 | 3 | var PooledMap = function() { 4 | this._keys = new PooledArray(); 5 | this._map = {}; 6 | }; 7 | 8 | PooledMap.prototype = { 9 | reset: function() { 10 | var array = this._keys.getArray(); 11 | var arrayLength = this._keys.getLength(); 12 | for (var i = 0; i < arrayLength; i++) { 13 | var key = array[i]; 14 | this._map[key] = undefined; 15 | } 16 | this._keys.reset(); 17 | }, 18 | /** 19 | * Set a key value 20 | * you have to check that the key does not exist before otherwise you could hit performance hit when calling reset/forEach 21 | */ 22 | set: function(key, value) { 23 | this._keys.push(key); 24 | this._map[key] = value; 25 | }, 26 | hasKey: function(key) { 27 | return this._map[key] !== undefined; 28 | }, 29 | getMap: function() { 30 | return this._map; 31 | }, 32 | getKeys: function() { 33 | return this._keys; 34 | }, 35 | forEach: function(func) { 36 | var array = this._keys.getArray(); 37 | var arrayLength = this._keys.getLength(); 38 | for (var i = 0; i < arrayLength; i++) { 39 | var key = array[i]; 40 | func(key, this._map[key]); 41 | } 42 | } 43 | }; 44 | 45 | export default PooledMap; 46 | -------------------------------------------------------------------------------- /sources/osg/PooledResource.js: -------------------------------------------------------------------------------- 1 | var PooledResource = function(createFunction) { 2 | this._createFunction = createFunction; 3 | this._pool = []; 4 | this._length = 0; 5 | }; 6 | 7 | PooledResource.prototype = { 8 | clean: function() { 9 | this._pool.length = 0; 10 | this._length = 0; 11 | }, 12 | getLength: function() { 13 | return this._length; 14 | }, 15 | reset: function() { 16 | this._length = 0; 17 | }, 18 | /** 19 | * Creates or returns an existing object. 20 | * The returned object could contain invalid data from previous object values. User is responsible to reset/init the returned object for its (re)use. 21 | */ 22 | getOrCreateObject: function() { 23 | var obj; 24 | if (this._length === this._pool.length) { 25 | obj = this._createFunction(); 26 | this._pool.push(obj); 27 | } else { 28 | obj = this._pool[this._length]; 29 | } 30 | this._length++; 31 | return obj; 32 | }, 33 | forEach: function(func) { 34 | for (var i = 0; i < this._length; i++) func(this._pool[i]); 35 | } 36 | }; 37 | 38 | export default PooledResource; 39 | -------------------------------------------------------------------------------- /sources/osg/Projection.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Node from 'osg/Node'; 3 | import { mat4 } from 'osg/glMatrix'; 4 | 5 | var Projection = function() { 6 | Node.call(this); 7 | this.projection = mat4.create(); 8 | }; 9 | 10 | utils.createPrototypeNode( 11 | Projection, 12 | utils.objectInherit(Node.prototype, { 13 | getProjectionMatrix: function() { 14 | return this.projection; 15 | }, 16 | setProjectionMatrix: function(m) { 17 | this.projection = m; 18 | } 19 | }), 20 | 'osg', 21 | 'Projection' 22 | ); 23 | 24 | export default Projection; 25 | -------------------------------------------------------------------------------- /sources/osg/Scissor.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import StateAttribute from 'osg/StateAttribute'; 3 | 4 | var Scissor = function(x, y, w, h) { 5 | StateAttribute.call(this); 6 | 7 | this._x = x !== undefined ? x : -1; 8 | this._y = y !== undefined ? y : -1; 9 | this._width = w !== undefined ? w : -1; 10 | 11 | this._height = h !== undefined ? h : -1; 12 | }; 13 | 14 | utils.createPrototypeStateAttribute( 15 | Scissor, 16 | utils.objectInherit(StateAttribute.prototype, { 17 | attributeType: 'Scissor', 18 | 19 | cloneType: function() { 20 | return new Scissor(); 21 | }, 22 | 23 | setScissor: function(x, y, width, height) { 24 | this._x = x; 25 | this._y = y; 26 | this._width = width; 27 | this._height = height; 28 | }, 29 | 30 | x: function() { 31 | return this._x; 32 | }, 33 | 34 | y: function() { 35 | return this._y; 36 | }, 37 | 38 | width: function() { 39 | return this._width; 40 | }, 41 | 42 | height: function() { 43 | return this._height; 44 | }, 45 | 46 | apply: function(state) { 47 | state.applyScissor(this); 48 | } 49 | }), 50 | 'osg', 51 | 'Scissor' 52 | ); 53 | 54 | export default Scissor; 55 | -------------------------------------------------------------------------------- /sources/osg/StackObjectPairPool.js: -------------------------------------------------------------------------------- 1 | var StackObjectPairPool = function() { 2 | this._globalDefault = undefined; 3 | this._lastApplied = undefined; 4 | this._changed = false; 5 | 6 | this._values = []; 7 | this._back = undefined; 8 | this._length = 0; 9 | }; 10 | 11 | StackObjectPairPool.prototype = { 12 | getLength: function() { 13 | return this._length; 14 | }, 15 | push: function(object, value) { 16 | var objectPair; 17 | if (this._length === this._values.length) { 18 | objectPair = { object: object, value: value }; 19 | this._values.push(objectPair); 20 | } else { 21 | objectPair = this._values[this._length]; 22 | objectPair.object = object; 23 | objectPair.value = value; 24 | } 25 | this._back = objectPair; 26 | this._length++; 27 | }, 28 | pop: function() { 29 | if (!this._length) return undefined; 30 | var values = this._values; 31 | this._length--; 32 | var objectPair = values[this._length]; 33 | this._back = this._length ? values[this._length - 1] : undefined; 34 | return objectPair; 35 | } 36 | }; 37 | export default StackObjectPairPool; 38 | -------------------------------------------------------------------------------- /sources/osg/StateAttribute.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | 4 | var StateAttribute = function() { 5 | Object.call(this); 6 | }; 7 | 8 | utils.createPrototypeStateAttribute( 9 | StateAttribute, 10 | utils.objectInherit(Object.prototype, { 11 | _attributeTypeIndex: undefined, 12 | 13 | getType: function() { 14 | return this.attributeType; 15 | }, 16 | 17 | // basically, if you want two StateAttribute with the same attributeType in a stateSet/State 18 | // their typeMember should be different 19 | getTypeMember: function() { 20 | return this.attributeType; 21 | }, 22 | 23 | apply: function() {}, 24 | 25 | // getHash is used by the compiler to know if a change in a StateAttribute 26 | // must trigger a shader build 27 | // If you create your own attribute you will have to customize this function 28 | // a good rule is to that if you change uniform it should not rebuild a shader 29 | // but if you change a type or representation of your StateAttribute, then it should 30 | // if it impact the rendering. 31 | // check other attributes for examples 32 | getHash: function() { 33 | return this.getType(); 34 | } 35 | }), 36 | 'osg', 37 | 'StateAttribute' 38 | ); 39 | 40 | StateAttribute.OFF = 0; 41 | StateAttribute.ON = 1; 42 | StateAttribute.OVERRIDE = 2; 43 | StateAttribute.PROTECTED = 4; 44 | StateAttribute.INHERIT = 8; 45 | 46 | export default StateAttribute; 47 | -------------------------------------------------------------------------------- /sources/osg/Timer.js: -------------------------------------------------------------------------------- 1 | // user performance if available or fallback 2 | 3 | var now = (function() { 4 | var w = window || global; // eslint-disable-line 5 | 6 | // if no window.performance 7 | if (w.performance === undefined) { 8 | return function() { 9 | return Date.now(); 10 | }; 11 | } 12 | 13 | var fn = 14 | w.performance.now || 15 | w.performance.mozNow || 16 | w.performance.msNow || 17 | w.performance.oNow || 18 | w.performance.webkitNow || 19 | function() { 20 | return Date.now(); 21 | }; 22 | return function() { 23 | return fn.apply(w.performance, arguments); 24 | }; 25 | })(); 26 | 27 | var Timer = function() {}; 28 | 29 | Timer.instance = function() { 30 | if (!Timer._instance) Timer._instance = new Timer(); 31 | 32 | return Timer._instance; 33 | }; 34 | 35 | Timer.tick = now; 36 | 37 | Timer.prototype = { 38 | // delta in seconds 39 | deltaS: function(t0, t1) { 40 | return (t1 - t0) / 1000.0; 41 | }, 42 | 43 | // delta in milliseconds 44 | deltaM: function(t0, t1) { 45 | return t1 - t0; 46 | }, 47 | 48 | tick: function() { 49 | return now(); 50 | } 51 | }; 52 | 53 | export default Timer; 54 | -------------------------------------------------------------------------------- /sources/osg/Transform.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Node from 'osg/Node'; 3 | import { mat4 } from 'osg/glMatrix'; 4 | import TransformEnums from 'osg/transformEnums'; 5 | 6 | /** 7 | * Transform - base class for Transform type node ( Camera, MatrixTransform ) 8 | * @class Transform 9 | * @inherits Node 10 | */ 11 | var Transform = function() { 12 | Node.call(this); 13 | this.referenceFrame = TransformEnums.RELATIVE_RF; 14 | }; 15 | 16 | /** @lends Transform.prototype */ 17 | utils.createPrototypeNode( 18 | Transform, 19 | utils.objectInherit(Node.prototype, { 20 | setReferenceFrame: function(value) { 21 | this.referenceFrame = value; 22 | }, 23 | getReferenceFrame: function() { 24 | return this.referenceFrame; 25 | }, 26 | 27 | computeBoundingSphere: (function() { 28 | var matrix = mat4.create(); 29 | return function(bSphere) { 30 | Node.prototype.computeBoundingSphere.call(this, bSphere); 31 | if (!bSphere.valid()) { 32 | return bSphere; 33 | } 34 | 35 | mat4.identity(matrix); 36 | // local to local world (not Global World) 37 | this.computeLocalToWorldMatrix(matrix); 38 | bSphere.transformMat4(bSphere, matrix); 39 | return bSphere; 40 | }; 41 | })() 42 | }), 43 | 'osg', 44 | 'Transform' 45 | ); 46 | 47 | export default Transform; 48 | -------------------------------------------------------------------------------- /sources/osg/computeMatrixFromNodePath.js: -------------------------------------------------------------------------------- 1 | import { mat4 } from 'osg/glMatrix'; 2 | import TransformEnums from 'osg/transformEnums'; 3 | 4 | var computeLocalToWorld = function(nodePath, ignoreCameras, userMatrix, nodePathIndex) { 5 | var ignoreCamera = ignoreCameras; 6 | var nodePathLength = nodePathIndex !== undefined ? nodePathIndex : nodePath.length; 7 | if (ignoreCamera === undefined) ignoreCamera = true; 8 | 9 | var matrix = userMatrix || mat4.create(); 10 | 11 | var j = 0; 12 | 13 | if (ignoreCamera) { 14 | for (j = nodePathLength - 1; j >= 0; j--) { 15 | var camera = nodePath[j]; 16 | 17 | if ( 18 | camera.className() === 'Camera' && 19 | (camera.getReferenceFrame() !== TransformEnums.RELATIVE_RF || 20 | camera.getParents().length === 0) 21 | ) { 22 | break; 23 | } 24 | } 25 | 26 | // because when we break it's to an index - 1 27 | // it works because if nothing camera found j == -1 at the end of the loop 28 | // and if we found a camera we want to start at the camera index + 1 29 | j += 1; 30 | } 31 | 32 | for (var i = j, l = nodePathLength; i < l; i++) { 33 | var node = nodePath[i]; 34 | 35 | if (node.computeLocalToWorldMatrix) { 36 | node.computeLocalToWorldMatrix(matrix); 37 | } 38 | } 39 | 40 | return matrix; 41 | }; 42 | 43 | export default { 44 | computeLocalToWorld: computeLocalToWorld 45 | }; 46 | -------------------------------------------------------------------------------- /sources/osg/cullVisitorHelper.js: -------------------------------------------------------------------------------- 1 | var applyFunctionArray = []; 2 | 3 | var registerApplyFunction = function(type, apply) { 4 | applyFunctionArray[type] = apply; 5 | }; 6 | 7 | var getApplyFunction = function(type) { 8 | return applyFunctionArray[type]; 9 | }; 10 | 11 | export default { 12 | applyFunctionArray: applyFunctionArray, 13 | registerApplyFunction: registerApplyFunction, 14 | getApplyFunction: getApplyFunction 15 | }; 16 | -------------------------------------------------------------------------------- /sources/osg/math.js: -------------------------------------------------------------------------------- 1 | var clamp = function(x, min, max) { 2 | // http://jsperf.com/math-clamp 3 | // http://jsperf.com/clamping-methods/2 4 | return Math.min(max, Math.max(min, x)); 5 | }; 6 | 7 | var smoothStep = function(edge0, edge1, x) { 8 | if (x <= edge0) return 0.0; 9 | if (x >= edge1) return 1.0; 10 | var y = (x - edge0) / (edge1 - edge0); 11 | return y * y * (3.0 - 2.0 * y); 12 | }; 13 | 14 | // native isNaN is slow (e.g: https://jsperf.com/isnan-performance/2) 15 | // note : native isNaN will return true for undefined but 16 | // this function assume that x is a number 17 | var fastIsNaN = function(x) { 18 | return x !== x; 19 | }; 20 | 21 | export default { 22 | clamp: clamp, 23 | smoothStep: smoothStep, 24 | isNaN: fastIsNaN 25 | }; 26 | -------------------------------------------------------------------------------- /sources/osg/primitiveSet.js: -------------------------------------------------------------------------------- 1 | var primitiveSet = {}; 2 | primitiveSet.POINTS = 0x0000; 3 | primitiveSet.LINES = 0x0001; 4 | primitiveSet.LINE_LOOP = 0x0002; 5 | primitiveSet.LINE_STRIP = 0x0003; 6 | primitiveSet.TRIANGLES = 0x0004; 7 | primitiveSet.TRIANGLE_STRIP = 0x0005; 8 | primitiveSet.TRIANGLE_FAN = 0x0006; 9 | 10 | export default primitiveSet; 11 | -------------------------------------------------------------------------------- /sources/osg/transformEnums.js: -------------------------------------------------------------------------------- 1 | export default { 2 | RELATIVE_RF: 0, 3 | ABSOLUTE_RF: 1 4 | }; 5 | -------------------------------------------------------------------------------- /sources/osgAnimation/AnimationUpdateCallback.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import MatrixTransform from 'osg/MatrixTransform'; 4 | 5 | /** 6 | * AnimationUpdateCallback 7 | * @class AnimationUpdateCallback 8 | */ 9 | var AnimationUpdateCallback = function() { 10 | Object.call(this); 11 | }; 12 | 13 | // check if the path is animated, it could be elsewhere though 14 | AnimationUpdateCallback.checkPathIsAnimated = function(path) { 15 | for (var i = 0, nbNodes = path.length; i < nbNodes; ++i) { 16 | var node = path[i]; 17 | 18 | if (node instanceof MatrixTransform) { 19 | var ups = node.getUpdateCallbackList(); 20 | for (var j = 0, nbUp = ups.length; j < nbUp; ++j) { 21 | if (ups[j] instanceof AnimationUpdateCallback) return true; 22 | } 23 | } 24 | } 25 | 26 | return false; 27 | }; 28 | 29 | /** @lends AnimationUpdateCallback.prototype */ 30 | utils.createPrototypeObject( 31 | AnimationUpdateCallback, 32 | utils.objectInherit(Object.prototype, { 33 | computeChannels: function() {}, 34 | reset: function() {} 35 | }), 36 | 'osgAnimation', 37 | 'AnimationUpdateCallback' 38 | ); 39 | 40 | export default AnimationUpdateCallback; 41 | -------------------------------------------------------------------------------- /sources/osgAnimation/CollectAnimationUpdateCallbackVisitor.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import NodeVisitor from 'osg/NodeVisitor'; 3 | import AnimationUpdateCallback from 'osgAnimation/AnimationUpdateCallback'; 4 | 5 | // search into a subgraph all target 6 | var CollectAnimationUpdateCallbackVisitor = function() { 7 | NodeVisitor.call(this); 8 | this._animationUpdateCallback = {}; 9 | }; 10 | 11 | utils.createPrototypeObject( 12 | CollectAnimationUpdateCallbackVisitor, 13 | utils.objectInherit(NodeVisitor.prototype, { 14 | getAnimationUpdateCallbackMap: function() { 15 | return this._animationUpdateCallback; 16 | }, 17 | 18 | apply: function(node) { 19 | var cbs = node.getUpdateCallbackList(); 20 | 21 | // collect and remove animation update callback 22 | for (var i = 0, cbsLength = cbs.length; i < cbsLength; i++) { 23 | var cb = cbs[i]; 24 | if (cb instanceof AnimationUpdateCallback) { 25 | this._animationUpdateCallback[cb.getInstanceID()] = cb; 26 | //node.removeUpdateCallback( cb ); 27 | } 28 | } 29 | this.traverse(node); 30 | } 31 | }), 32 | 'osgAnimation', 33 | 'CollectAnimationUpdateCallbackVisitor' 34 | ); 35 | 36 | export default CollectAnimationUpdateCallbackVisitor; 37 | -------------------------------------------------------------------------------- /sources/osgAnimation/CollectBoneVisitor.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import NodeVisitor from 'osg/NodeVisitor'; 3 | import notify from 'osg/notify'; 4 | import Bone from 'osgAnimation/Bone'; 5 | 6 | var CollectBoneVisitor = function() { 7 | NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN); 8 | this._boneMap = {}; 9 | }; 10 | 11 | utils.createPrototypeObject( 12 | CollectBoneVisitor, 13 | utils.objectInherit(NodeVisitor.prototype, { 14 | apply: function(node) { 15 | if (node.typeID === Bone.typeID) { 16 | var name = node.getName(); 17 | 18 | if (!name) { 19 | notify.warn('found Bone without name'); 20 | } else { 21 | this._boneMap[name] = node; 22 | } 23 | } 24 | 25 | this.traverse(node); 26 | }, 27 | 28 | getBoneMap: function() { 29 | return this._boneMap; 30 | } 31 | }), 32 | 'osgAnimation', 33 | 'CollectBoneVisitor' 34 | ); 35 | 36 | export default CollectBoneVisitor; 37 | -------------------------------------------------------------------------------- /sources/osgAnimation/FindNearestParentSkeleton.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import NodeVisitor from 'osg/NodeVisitor'; 3 | import Skeleton from 'osgAnimation/Skeleton'; 4 | 5 | /** 6 | * FindNearestParentSkeleton 7 | */ 8 | 9 | var FindNearestParentSkeleton = function() { 10 | NodeVisitor.call(this, NodeVisitor.TRAVERSE_PARENTS); 11 | this._root = undefined; 12 | 13 | // node path to skeleton (without skeleton node though) 14 | this._pathToRoot = undefined; 15 | }; 16 | 17 | utils.createPrototypeObject( 18 | FindNearestParentSkeleton, 19 | utils.objectInherit(NodeVisitor.prototype, { 20 | apply: function(node) { 21 | if (this._root) return; 22 | 23 | if (node.typeID === Skeleton.typeID) { 24 | this._root = node; 25 | this._pathToRoot = this.nodePath.slice(1); 26 | return; 27 | } 28 | 29 | this.traverse(node); 30 | } 31 | }), 32 | 'osgAnimation', 33 | 'FindNearestParentSkeleton' 34 | ); 35 | 36 | export default FindNearestParentSkeleton; 37 | -------------------------------------------------------------------------------- /sources/osgAnimation/Skeleton.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import MatrixTransform from 'osg/MatrixTransform'; 3 | import UpdateSkeleton from 'osgAnimation/UpdateSkeleton'; 4 | import NodeVisitor from 'osg/NodeVisitor'; 5 | import UpdateMatrixTransform from 'osgAnimation/UpdateMatrixTransform'; 6 | import Bone from 'osgAnimation/Bone'; 7 | 8 | var ResetRestPoseVisitor = function() { 9 | NodeVisitor.call(this, NodeVisitor.TRAVERSE_ALL_CHILDREN); 10 | }; 11 | 12 | utils.createPrototypeObject( 13 | ResetRestPoseVisitor, 14 | utils.objectInherit(NodeVisitor.prototype, { 15 | apply: function(node) { 16 | if (node.getTypeID() === Bone.getTypeID()) { 17 | var cb = node.getUpdateCallback(); 18 | if (cb instanceof UpdateMatrixTransform) { 19 | var stackedTransforms = cb._stackedTransforms; 20 | for (var st = 0, l = stackedTransforms.length; st < l; st++) { 21 | var stackedTransform = stackedTransforms[st]; 22 | stackedTransform.resetToDefaultValue(); 23 | } 24 | cb.computeChannels(); 25 | } 26 | } 27 | this.traverse(node); 28 | } 29 | }), 30 | 'osgAnimation', 31 | 'ResetRestPoseVisitor' 32 | ); 33 | 34 | var resetter = new ResetRestPoseVisitor(); 35 | 36 | var Skeleton = function() { 37 | MatrixTransform.call(this); 38 | }; 39 | 40 | utils.createPrototypeNode( 41 | Skeleton, 42 | utils.objectInherit(MatrixTransform.prototype, { 43 | setDefaultUpdateCallback: function() { 44 | this.addUpdateCallback(new UpdateSkeleton()); 45 | }, 46 | 47 | setRestPose: function() { 48 | this.accept(resetter); 49 | } 50 | }), 51 | 'osgAnimation', 52 | 'Skeleton' 53 | ); 54 | 55 | export default Skeleton; 56 | -------------------------------------------------------------------------------- /sources/osgAnimation/StackedMatrix.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import { mat4 } from 'osg/glMatrix'; 4 | import Target from 'osgAnimation/target'; 5 | 6 | var StackedMatrix = function(name, matrix) { 7 | Object.call(this); 8 | this._target = Target.createMatrixTarget(matrix || mat4.IDENTITY); 9 | if (name) this.setName(name); 10 | }; 11 | 12 | utils.createPrototypeObject( 13 | StackedMatrix, 14 | utils.objectInherit(Object.prototype, { 15 | init: function(matrix) { 16 | this.setMatrix(matrix); 17 | mat4.copy(this._target.defaultValue, matrix); 18 | }, 19 | 20 | getTarget: function() { 21 | return this._target; 22 | }, 23 | 24 | getMatrix: function() { 25 | return this._target.value; 26 | }, 27 | 28 | setMatrix: function(m) { 29 | mat4.copy(this._target.value, m); 30 | }, 31 | 32 | resetToDefaultValue: function() { 33 | this.setMatrix(this._target.defaultValue); 34 | }, 35 | 36 | applyToMatrix: function(m) { 37 | mat4.mul(m, m, this._target.value); 38 | } 39 | }), 40 | 'osgAnimation', 41 | 'StackedMatrix' 42 | ); 43 | 44 | export default StackedMatrix; 45 | -------------------------------------------------------------------------------- /sources/osgAnimation/StackedQuaternion.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import { mat4 } from 'osg/glMatrix'; 4 | import { quat } from 'osg/glMatrix'; 5 | import Target from 'osgAnimation/target'; 6 | 7 | var qIdentity = quat.create(); 8 | 9 | var StackedQuaternion = function(name, q) { 10 | Object.call(this); 11 | this._target = Target.createQuatTarget(q || qIdentity); 12 | if (name) this.setName(name); 13 | }; 14 | 15 | utils.createPrototypeObject( 16 | StackedQuaternion, 17 | utils.objectInherit(Object.prototype, { 18 | init: function(q) { 19 | this.setQuaternion(q); 20 | quat.copy(this._target.defaultValue, q); 21 | }, 22 | 23 | setQuaternion: function(q) { 24 | quat.copy(this._target.value, q); 25 | }, 26 | 27 | getTarget: function() { 28 | return this._target; 29 | }, 30 | 31 | resetToDefaultValue: function() { 32 | this.setQuaternion(this._target.defaultValue); 33 | }, 34 | 35 | applyToMatrix: (function() { 36 | var matrixTmp = mat4.create(); 37 | 38 | return function applyToMatrix(m) { 39 | var mtmp = matrixTmp; 40 | mat4.fromQuat(mtmp, this._target.value); 41 | mat4.mul(m, m, mtmp); 42 | }; 43 | })() 44 | }), 45 | 'osgAnimation', 46 | 'StackedQuaternion' 47 | ); 48 | 49 | export default StackedQuaternion; 50 | -------------------------------------------------------------------------------- /sources/osgAnimation/StackedScale.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import { mat4 } from 'osg/glMatrix'; 4 | import { vec3 } from 'osg/glMatrix'; 5 | import Target from 'osgAnimation/target'; 6 | 7 | var StackedScale = function(name, scale) { 8 | Object.call(this); 9 | this._target = Target.createVec3Target(scale || vec3.ONE); 10 | if (name) this.setName(name); 11 | }; 12 | 13 | utils.createPrototypeObject( 14 | StackedScale, 15 | utils.objectInherit(Object.prototype, { 16 | init: function(scale) { 17 | this.setScale(scale); 18 | vec3.copy(this._target.defaultValue, scale); 19 | }, 20 | 21 | setScale: function(scale) { 22 | vec3.copy(this._target.value, scale); 23 | }, 24 | 25 | getTarget: function() { 26 | return this._target; 27 | }, 28 | 29 | resetToDefaultValue: function() { 30 | this.setScale(this._target.defaultValue); 31 | }, 32 | 33 | // must be optimized 34 | applyToMatrix: function(m) { 35 | var scale = this._target.value; 36 | mat4.scale(m, m, scale); 37 | } 38 | }), 39 | 'osgAnimation', 40 | 'StackedScale' 41 | ); 42 | 43 | export default StackedScale; 44 | -------------------------------------------------------------------------------- /sources/osgAnimation/StackedTranslate.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import { vec3 } from 'osg/glMatrix'; 4 | import { mat4 } from 'osg/glMatrix'; 5 | import Target from 'osgAnimation/target'; 6 | 7 | /** 8 | * StackedTranslate 9 | */ 10 | var StackedTranslate = function(name, translate) { 11 | Object.call(this); 12 | this._target = Target.createVec3Target(translate || vec3.ZERO); 13 | if (name) this.setName(name); 14 | }; 15 | 16 | utils.createPrototypeObject( 17 | StackedTranslate, 18 | utils.objectInherit(Object.prototype, { 19 | init: function(translate) { 20 | this.setTranslate(translate); 21 | vec3.copy(this._target.defaultValue, translate); 22 | }, 23 | 24 | setTranslate: function(translate) { 25 | vec3.copy(this._target.value, translate); 26 | }, 27 | 28 | getTarget: function() { 29 | return this._target; 30 | }, 31 | 32 | resetToDefaultValue: function() { 33 | this.setTranslate(this._target.defaultValue); 34 | }, 35 | 36 | applyToMatrix: function(m) { 37 | mat4.translate(m, m, this._target.value); 38 | } 39 | }), 40 | 'osgAnimation', 41 | 'StackedTranslate' 42 | ); 43 | 44 | export default StackedTranslate; 45 | -------------------------------------------------------------------------------- /sources/osgAnimation/UpdateBone.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import notify from 'osg/notify'; 3 | import UpdateMatrixTransform from 'osgAnimation/UpdateMatrixTransform'; 4 | import { mat4 } from 'osg/glMatrix'; 5 | import NodeVisitor from 'osg/NodeVisitor'; 6 | 7 | /** 8 | * UpdateBone 9 | * @class UpdateBone 10 | */ 11 | var UpdateBone = function() { 12 | UpdateMatrixTransform.call(this); 13 | }; 14 | 15 | /** @lends UpdateBone.prototype */ 16 | utils.createPrototypeObject( 17 | UpdateBone, 18 | utils.objectInherit(UpdateMatrixTransform.prototype, { 19 | update: function(node, nv) { 20 | if (nv.getVisitorType() === NodeVisitor.UPDATE_VISITOR) { 21 | if (node.className && node.className() !== 'Bone') { 22 | notify.warn('Warning: UpdateBone set on non-Bone object.'); 23 | return false; 24 | } 25 | 26 | var bone = node; 27 | 28 | UpdateMatrixTransform.prototype.update.call(this, node); 29 | bone.setMatrix(bone.getMatrix()); 30 | var matrix = bone.getMatrix(); 31 | var parent = bone.getBoneParent(); 32 | 33 | if (parent) { 34 | mat4.mul( 35 | bone.getMatrixInSkeletonSpace(), 36 | parent.getMatrixInSkeletonSpace(), 37 | matrix 38 | ); 39 | } else { 40 | bone.setMatrixInSkeletonSpace(matrix); 41 | } 42 | } 43 | return true; 44 | } 45 | }), 46 | 'osgAnimation', 47 | 'UpdateBone' 48 | ); 49 | 50 | export default UpdateBone; 51 | -------------------------------------------------------------------------------- /sources/osgAnimation/animation.js: -------------------------------------------------------------------------------- 1 | import Channel from 'osgAnimation/channel'; 2 | 3 | // create Animation data 4 | // Animation { 5 | // channels: [], 6 | // duration: 0.0; 7 | // name: string 8 | // }, 9 | 10 | var animationCount = 0; 11 | 12 | // assume that iniChannel has been called 13 | // on each channel 14 | var createAnimation = function(channels, name) { 15 | var min = Infinity; 16 | var max = -Infinity; 17 | for (var i = 0; i < channels.length; i++) { 18 | min = Math.min(min, channels[i].start); 19 | max = Math.max(max, channels[i].end); 20 | } 21 | 22 | var duration = max - min; 23 | var animationName = name || 'animation' + animationCount.toString(); 24 | animationCount++; 25 | return { 26 | channels: channels, 27 | duration: duration, 28 | name: animationName, 29 | start: min 30 | }; 31 | }; 32 | 33 | // create instance Animation data. An instance animation 34 | // contains instance channels instead of original channels 35 | // Animation { 36 | // channels: [], 37 | // duration: 0.0; 38 | // start: 0.0, // used to know when an animation has been started 39 | // name: string 40 | // }, 41 | var createInstanceAnimation = function(animation) { 42 | var channels = []; 43 | for (var i = 0; i < animation.channels.length; i++) { 44 | var channel = Channel.createInstanceChannel(animation.channels[i]); 45 | channels.push(channel); 46 | } 47 | 48 | return { 49 | channels: channels, 50 | duration: animation.duration, 51 | start: 0.0, 52 | name: animation.name, 53 | firstKeyTime: animation.start 54 | }; 55 | }; 56 | 57 | var Animation = function() {}; 58 | 59 | Animation.createAnimation = createAnimation; 60 | Animation.createInstanceAnimation = createInstanceAnimation; 61 | 62 | export default Animation; 63 | -------------------------------------------------------------------------------- /sources/osgAnimation/channelType.js: -------------------------------------------------------------------------------- 1 | // must be sync wiht Interpolator Type 2 | export default { 3 | Vec3: 0, 4 | Quat: 1, 5 | Float: 2, 6 | FloatCubicBezier: 3, 7 | Vec3CubicBezier: 4, 8 | QuatSlerp: 5, 9 | Matrix: 6, 10 | Count: 7 11 | }; 12 | -------------------------------------------------------------------------------- /sources/osgAnimation/target.js: -------------------------------------------------------------------------------- 1 | import { mat4 } from 'osg/glMatrix'; 2 | import { quat } from 'osg/glMatrix'; 3 | import { vec3 } from 'osg/glMatrix'; 4 | import channelType from 'osgAnimation/channelType'; 5 | 6 | var target = {}; 7 | target.InvalidTargetID = -1; 8 | 9 | // defaultValue is used when no channels affect the value 10 | var createTarget = function(type, value, defaultValue) { 11 | return { 12 | type: type, 13 | id: target.InvalidTargetID, // -1 means no id assigned yet 14 | channels: [], 15 | value: value, 16 | defaultValue: defaultValue 17 | }; 18 | }; 19 | 20 | var createQuatTarget = function(defaultValue) { 21 | return createTarget( 22 | channelType.Quat, 23 | quat.copy(quat.create(), defaultValue), 24 | quat.copy(quat.create(), defaultValue) 25 | ); 26 | }; 27 | 28 | var createMatrixTarget = function(defaultValue) { 29 | return createTarget( 30 | channelType.Matrix, 31 | mat4.copy(mat4.create(), defaultValue), 32 | mat4.copy(mat4.create(), defaultValue) 33 | ); 34 | }; 35 | 36 | var createVec3Target = function(defaultValue) { 37 | return createTarget( 38 | channelType.Vec3, 39 | vec3.copy(vec3.create(), defaultValue), 40 | vec3.copy(vec3.create(), defaultValue) 41 | ); 42 | }; 43 | 44 | var createFloatTarget = function(defaultValue) { 45 | return createTarget(channelType.Float, defaultValue, defaultValue); 46 | }; 47 | 48 | target.createQuatTarget = createQuatTarget; 49 | target.createVec3Target = createVec3Target; 50 | target.createFloatTarget = createFloatTarget; 51 | target.createMatrixTarget = createMatrixTarget; 52 | 53 | export default target; 54 | -------------------------------------------------------------------------------- /sources/osgDB/Registry.js: -------------------------------------------------------------------------------- 1 | import notify from 'osg/notify'; 2 | 3 | /** 4 | * This is a very simplistic version of the OSG registry, we could 5 | * expand/improve it in the future 6 | */ 7 | 8 | var Registry = { 9 | instance: function() { 10 | if (!Registry._instance) { 11 | Registry._instance = Registry; 12 | Registry._instance.plugins = new window.Map(); 13 | } 14 | return Registry._instance; 15 | }, 16 | 17 | // We register directly a plugin for a extension. 18 | addReaderWriter: function(extension, plugin) { 19 | if (Registry.instance().plugins.get(extension) !== undefined) 20 | notify.warn("the '" + extension + "' plugin already exists"); 21 | Registry.instance().plugins.set(extension, plugin); 22 | }, 23 | 24 | getReaderWriterForExtension: function(name) { 25 | return Registry.instance().plugins.get(name); 26 | } 27 | }; 28 | 29 | export default Registry; 30 | -------------------------------------------------------------------------------- /sources/osgDB/options.js: -------------------------------------------------------------------------------- 1 | var defaultOptions = { 2 | // prefix to built url to load resource 3 | prefixURL: '', 4 | 5 | // database URL for PagedLOD structures 6 | databasePath: '', 7 | 8 | // callback used when loading data 9 | progressXHRCallback: undefined, 10 | 11 | // replacement of readImageURL to use your own code to load Nodes 12 | // the function will be execute in the context of Input, see Input:readNodeURL 13 | readNodeURL: undefined, 14 | 15 | // replacement of readImageURL to use your own code to load osg.Image 16 | // the function will be execute in the context of Input, see Input:readImageURL 17 | readImageURL: undefined, 18 | 19 | // replacement of readBinaryArrayURL to use your own code to load binary array 20 | // the function will be execute in the context of Input, see Input:readBinaryArrayURL 21 | readBinaryArrayURL: undefined, 22 | 23 | imageLoadingUsePromise: true, // use promise to load image instead of returning Image 24 | imageOnload: undefined, // use callback when loading an image 25 | imageCrossOrigin: undefined // use callback when loading an image 26 | }; 27 | 28 | export default defaultOptions; 29 | -------------------------------------------------------------------------------- /sources/osgDB/osgDB.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Input from 'osgDB/Input'; 3 | import ReaderParser from 'osgDB/readerParser'; 4 | import DatabasePager from 'osgDB/DatabasePager'; 5 | import osgWrappers from 'osgWrappers/serializers/osg'; 6 | import osgAnimationWrappers from 'osgWrappers/serializers/osgAnimation'; 7 | import osgTextWrappers from 'osgWrappers/serializers/osgText'; 8 | import Registry from 'osgDB/Registry'; 9 | import fileHelper from 'osgDB/fileHelper'; 10 | import requestFile from 'osgDB/requestFile'; 11 | import zlib from 'osgDB/zlib'; 12 | 13 | var osgDB = {}; 14 | osgDB.Input = Input; 15 | utils.objectMix(osgDB, ReaderParser); 16 | osgDB.DatabasePager = DatabasePager; 17 | osgDB.ObjectWrapper.serializers.osg = osgWrappers; 18 | osgDB.ObjectWrapper.serializers.osgAnimation = osgAnimationWrappers; 19 | osgDB.ObjectWrapper.serializers.osgText = osgTextWrappers; 20 | osgDB.Registry = Registry; 21 | osgDB.fileHelper = fileHelper; 22 | osgDB.requestFile = requestFile; 23 | 24 | utils.objectMix(osgDB, zlib); 25 | 26 | export default osgDB; 27 | -------------------------------------------------------------------------------- /sources/osgDB/zlib.js: -------------------------------------------------------------------------------- 1 | import notify from 'osg/notify'; 2 | 3 | var isBufferGZIP = function(arrayBuffer) { 4 | var typedArray = new Uint8Array(arrayBuffer); 5 | return typedArray[0] === 0x1f && typedArray[1] === 0x8b; 6 | }; 7 | 8 | var gunzip = function(arrayBuffer) { 9 | var typedArray = new Uint8Array(arrayBuffer); 10 | var zlib = require('zlib'); 11 | 12 | if (!zlib) { 13 | notify.error( 14 | 'osg failed to use a gunzip.min.js to uncompress a gz file.\n You can add this vendors to enable this feature or get it at https://github.com/imaya/zlib.js/blob/master/bin/gunzip.min.js' 15 | ); 16 | } 17 | 18 | var zdec = new zlib.Gunzip(typedArray); 19 | var result = zdec.decompress(); 20 | return result.buffer; 21 | }; 22 | 23 | export default { 24 | isGunzipBuffer: isBufferGZIP, 25 | gunzip: gunzip 26 | }; 27 | -------------------------------------------------------------------------------- /sources/osgGA/CADManipulatorHammerController.js: -------------------------------------------------------------------------------- 1 | import OrbitManipulatorHammerController from 'osgGA/OrbitManipulatorHammerController'; 2 | import InputGroups from 'osgViewer/input/InputConstants'; 3 | import utils from 'osg/utils'; 4 | 5 | var CADManipulatorHammerController = function(manipulator) { 6 | OrbitManipulatorHammerController.call(this, manipulator); 7 | this._timer = false; 8 | }; 9 | 10 | utils.createPrototypeObject( 11 | CADManipulatorHammerController, 12 | utils.objectInherit(OrbitManipulatorHammerController.prototype, { 13 | _initInputs: function() { 14 | OrbitManipulatorHammerController.prototype._initInputs.call( 15 | this, 16 | InputGroups.CAD_MANIPULATOR_TOUCH 17 | ); 18 | }, 19 | 20 | startMotion: function(interpolator, factor, ev) { 21 | OrbitManipulatorHammerController.prototype.startMotion.call( 22 | this, 23 | interpolator, 24 | factor, 25 | ev 26 | ); 27 | this._manipulator.computeIntersections(ev.glX, ev.glY); 28 | } 29 | }) 30 | ); 31 | 32 | export default CADManipulatorHammerController; 33 | -------------------------------------------------------------------------------- /sources/osgGA/Controller.js: -------------------------------------------------------------------------------- 1 | var Controller = function(manipulator) { 2 | this._manipulator = manipulator; 3 | this._enable = true; 4 | }; 5 | 6 | Controller.prototype = { 7 | // All eventProxy must check isEnabled before injecting 8 | // event into Controllers 9 | isEnabled: function() { 10 | return this._enable; 11 | }, 12 | 13 | // called to enable/disable a Controller 14 | // it should be customized for controller that keeps states 15 | // on events 16 | setEnable: function(bool) { 17 | this._enable = bool; 18 | } 19 | }; 20 | 21 | export default Controller; 22 | -------------------------------------------------------------------------------- /sources/osgGA/FirstPersonManipulatorHammerController.js: -------------------------------------------------------------------------------- 1 | import OrbitManipulatorHammerController from 'osgGA/OrbitManipulatorHammerController'; 2 | import InputGroups from 'osgViewer/input/InputConstants'; 3 | import utils from 'osg/utils'; 4 | 5 | var FirstPersonManipulatorHammerController = function(manipulator) { 6 | OrbitManipulatorHammerController.call(this, manipulator); 7 | this._timer = false; 8 | }; 9 | 10 | utils.createPrototypeObject( 11 | FirstPersonManipulatorHammerController, 12 | utils.objectInherit(OrbitManipulatorHammerController.prototype, { 13 | _initInputs: function() { 14 | OrbitManipulatorHammerController.prototype._initInputs.call( 15 | this, 16 | InputGroups.FPS_MANIPULATOR_TOUCH 17 | ); 18 | } 19 | }) 20 | ); 21 | 22 | export default FirstPersonManipulatorHammerController; 23 | -------------------------------------------------------------------------------- /sources/osgGA/orbitManipulatorEnums.js: -------------------------------------------------------------------------------- 1 | export default { 2 | ROTATE: 0, 3 | PAN: 1, 4 | ZOOM: 2 5 | }; 6 | -------------------------------------------------------------------------------- /sources/osgNameSpace.js: -------------------------------------------------------------------------------- 1 | import pkg from 'json-loader!../package.json'; 2 | 3 | export default { 4 | name: pkg.name, 5 | version: pkg.version, 6 | author: pkg.author 7 | }; 8 | -------------------------------------------------------------------------------- /sources/osgPlugins/osgPlugins.js: -------------------------------------------------------------------------------- 1 | import ReaderWriterGLTF from 'osgPlugins/ReaderWriterGLTF'; 2 | import ReaderWriterZIP from 'osgPlugins/ReaderWriterZIP'; 3 | 4 | var osgPlugins = {}; 5 | 6 | osgPlugins.ReaderWriterGLTF = ReaderWriterGLTF; 7 | osgPlugins.ReaderWriterZIP = ReaderWriterZIP; 8 | 9 | export default osgPlugins; 10 | -------------------------------------------------------------------------------- /sources/osgShader/ShaderGeneratorProxy.js: -------------------------------------------------------------------------------- 1 | import notify from 'osg/notify'; 2 | import ShaderGenerator from 'osgShader/ShaderGenerator'; 3 | import ShadowCastShaderGenerator from 'osgShadow/ShadowCastShaderGenerator'; 4 | import DisplayNormalVisitor from 'osgUtil/DisplayNormalVisitor'; 5 | import DisplayGeometryVisitor from 'osgUtil/DisplayGeometryVisitor'; 6 | 7 | var ShaderGeneratorProxy = function() { 8 | // object of shader generators 9 | this._generators = {}; 10 | this.addShaderGenerator('default', new ShaderGenerator()); 11 | this.addShaderGenerator('ShadowCast', new ShadowCastShaderGenerator()); 12 | this.addShaderGenerator( 13 | 'debugNormal', 14 | new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetNormal() 15 | ); 16 | this.addShaderGenerator( 17 | 'debugTangent', 18 | new DisplayNormalVisitor.ShaderGeneratorCompilerOffsetTangent() 19 | ); 20 | this.addShaderGenerator( 21 | 'debugGeometry', 22 | new DisplayGeometryVisitor.ShaderGeneratorCompilerColorGeometry() 23 | ); 24 | this.addShaderGenerator( 25 | 'debugSkinning', 26 | new DisplayGeometryVisitor.ShaderGeneratorCompilerColorSkinning() 27 | ); 28 | 29 | return this; 30 | }; 31 | 32 | ShaderGeneratorProxy.prototype = { 33 | getShaderGenerator: function(name) { 34 | if (!name) return this._generators.default; 35 | 36 | var shaderGenerator = this._generators[name]; 37 | 38 | if (!shaderGenerator) { 39 | notify.error('ShaderGenerator ' + name + ' does not exist in ShaderGeneratorProxy'); 40 | return this._generators.default; 41 | } 42 | 43 | return shaderGenerator; 44 | }, 45 | 46 | // user-space facility to provide its own 47 | addShaderGenerator: function(name, sg) { 48 | this._generators[name] = sg; 49 | } 50 | }; 51 | 52 | export default ShaderGeneratorProxy; 53 | -------------------------------------------------------------------------------- /sources/osgShader/node/billboard.glsl: -------------------------------------------------------------------------------- 1 | vec3 getScale( const in mat4 matrix ) { 2 | // Only working with positive scales. 3 | float xs = matrix[0][0] * matrix[0][1] * matrix[0][2] * matrix[0][3] < 0. ? -1. : 1.; 4 | float ys = matrix[1][0] * matrix[1][1] * matrix[1][2] * matrix[1][3] < 0. ? -1. : 1.; 5 | float zs = matrix[2][0] * matrix[2][1] * matrix[2][2] * matrix[2][3] < 0. ? -1. : 1.; 6 | vec3 scale; 7 | scale.x = xs * sqrt( matrix[0][0] * matrix[0][0] + matrix[0][1] * matrix[0][1] + matrix[0][2] * matrix[0][2]); 8 | scale.y = ys * sqrt( matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]); 9 | scale.z = zs * sqrt( matrix[2][0] * matrix[2][0] + matrix[2][1] * matrix[2][1] + matrix[2][2] * matrix[2][2]); 10 | return scale; 11 | } 12 | 13 | #pragma DECLARE_FUNCTION 14 | vec4 billboard( const in vec3 vertex, const in mat4 modelViewMatrix, const in mat4 projectionMatrix ) { 15 | vec3 scale = getScale( modelViewMatrix ); 16 | return projectionMatrix * ( vec4( scale.x* vertex.x , scale.y * vertex.y, scale.z * vertex.z, 1.0 ) + vec4( modelViewMatrix[ 3 ].xyz, 0.0 ) ); 17 | } 18 | -------------------------------------------------------------------------------- /sources/osgShader/node/colorEncode.glsl: -------------------------------------------------------------------------------- 1 | 2 | float decodeFloatRGBA( vec4 rgba ) { 3 | return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0) ); 4 | } 5 | 6 | vec4 encodeFloatRGBA( float v ) { 7 | vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v; 8 | enc = fract(enc); 9 | enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0); 10 | return enc; 11 | } 12 | 13 | vec2 decodeHalfFloatRGBA( vec4 rgba ) { 14 | return vec2(rgba.x + (rgba.y / 255.0), rgba.z + (rgba.w / 255.0)); 15 | } 16 | 17 | vec4 encodeHalfFloatRGBA( vec2 v ) { 18 | const vec2 bias = vec2(1.0 / 255.0, 0.0); 19 | vec4 enc; 20 | enc.xy = vec2(v.x, fract(v.x * 255.0)); 21 | enc.xy = enc.xy - (enc.yy * bias); 22 | 23 | enc.zw = vec2(v.y, fract(v.y * 255.0)); 24 | enc.zw = enc.zw - (enc.ww * bias); 25 | return enc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/osgShader/node/common.glsl: -------------------------------------------------------------------------------- 1 | #define PI 3.141593 2 | #define saturate(_x) clamp(_x, 0., 1.) 3 | -------------------------------------------------------------------------------- /sources/osgShader/node/morphing.glsl: -------------------------------------------------------------------------------- 1 | #pragma DECLARE_FUNCTION 2 | vec3 morphing( 3 | const in vec4 weights, 4 | const in vec3 vertex, 5 | const in vec3 target0) { 6 | 7 | return mix(vertex, target0, weights[0]); 8 | } 9 | 10 | #pragma DECLARE_FUNCTION 11 | vec3 morphing( 12 | const in vec4 weights, 13 | const in vec3 vertex, 14 | const in vec3 target0, 15 | const in vec3 target1) { 16 | 17 | vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1])); 18 | vecOut += target0 * weights[0]; 19 | vecOut += target1 * weights[1]; 20 | return vecOut; 21 | } 22 | 23 | #pragma DECLARE_FUNCTION 24 | vec3 morphing( 25 | const in vec4 weights, 26 | const in vec3 vertex, 27 | const in vec3 target0, 28 | const in vec3 target1, 29 | const in vec3 target2) { 30 | 31 | vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2])); 32 | vecOut += target0 * weights[0]; 33 | vecOut += target1 * weights[1]; 34 | vecOut += target2 * weights[2]; 35 | return vecOut; 36 | } 37 | 38 | #pragma DECLARE_FUNCTION 39 | vec3 morphing( 40 | const in vec4 weights, 41 | const in vec3 vertex, 42 | const in vec3 target0, 43 | const in vec3 target1, 44 | const in vec3 target2, 45 | const in vec3 target3) { 46 | 47 | vec3 vecOut = vertex * (1.0 - ( weights[0] + weights[1] + weights[2] + weights[3])); 48 | vecOut += target0 * weights[0]; 49 | vecOut += target1 * weights[1]; 50 | vecOut += target2 * weights[2]; 51 | vecOut += target3 * weights[3]; 52 | return vecOut; 53 | } 54 | -------------------------------------------------------------------------------- /sources/osgShader/node/textures.glsl: -------------------------------------------------------------------------------- 1 | #pragma DECLARE_FUNCTION 2 | vec3 textureRGB(const in sampler2D tex, const in vec2 uv) { 3 | return texture2D(tex, uv.xy).rgb; 4 | } 5 | 6 | #pragma DECLARE_FUNCTION 7 | vec4 textureRGBA(const in sampler2D tex, const in vec2 uv) { 8 | return texture2D(tex, uv.xy).rgba; 9 | } 10 | 11 | #pragma DECLARE_FUNCTION 12 | float textureIntensity(const in sampler2D tex, const in vec2 uv) { 13 | return texture2D(tex, uv).r; 14 | } 15 | 16 | #pragma DECLARE_FUNCTION 17 | float textureAlpha(const in sampler2D tex, const in vec2 uv) { 18 | return texture2D(tex, uv.xy).a; 19 | } 20 | -------------------------------------------------------------------------------- /sources/osgShader/osgShader.js: -------------------------------------------------------------------------------- 1 | import Compiler from 'osgShader/Compiler'; 2 | import ShaderGenerator from 'osgShader/ShaderGenerator'; 3 | import ShaderGeneratorProxy from 'osgShader/ShaderGeneratorProxy'; 4 | import ShaderProcessor from 'osgShader/ShaderProcessor'; 5 | import nodeFactory from 'osgShader/nodeFactory'; 6 | import Node from 'osgShader/node/Node'; 7 | import utils from 'osgShader/utils'; 8 | 9 | var lib = {}; 10 | 11 | lib.Compiler = Compiler; 12 | lib.ShaderGenerator = ShaderGenerator; 13 | lib.ShaderGeneratorProxy = ShaderGeneratorProxy; 14 | lib.ShaderProcessor = ShaderProcessor; 15 | lib.nodeFactory = nodeFactory; 16 | lib.utils = utils; 17 | 18 | lib.node = {}; 19 | lib.node.Node = Node; // used for inheritance 20 | nodeFactory._nodes.forEach(function(value, key) { 21 | lib.node[key] = value; 22 | }); 23 | 24 | // debug utility: set it to one to have verbose in shaders 25 | lib.debugShaderNode = false; 26 | /*develblock:start*/ 27 | lib.debugShaderNode = true; 28 | /*develblock:end*/ 29 | 30 | export default lib; 31 | -------------------------------------------------------------------------------- /sources/osgShader/shaderLib.js: -------------------------------------------------------------------------------- 1 | import common from 'osgShader/node/common.glsl'; 2 | import functions from 'osgShader/node/functions.glsl'; 3 | import lightCommon from 'osgShader/node/lightCommon.glsl'; 4 | import lights from 'osgShader/node/lights.glsl'; 5 | import skinning from 'osgShader/node/skinning.glsl'; 6 | import morphing from 'osgShader/node/morphing.glsl'; 7 | import textures from 'osgShader/node/textures.glsl'; 8 | import colorEncode from 'osgShader/node/colorEncode.glsl'; 9 | import billboard from 'osgShader/node/billboard.glsl'; 10 | 11 | export default { 12 | 'common.glsl': common, 13 | 'functions.glsl': functions, 14 | 'lightCommon.glsl': lightCommon, 15 | 'lights.glsl': lights, 16 | 'skinning.glsl': skinning, 17 | 'morphing.glsl': morphing, 18 | 'textures.glsl': textures, 19 | 'colorEncode.glsl': colorEncode, 20 | 'billboard.glsl': billboard 21 | }; 22 | -------------------------------------------------------------------------------- /sources/osgShadow/ShadowCastShaderGenerator.js: -------------------------------------------------------------------------------- 1 | import ShaderGenerator from 'osgShader/ShaderGenerator'; 2 | import ShadowCompiler from 'osgShadow/ShadowCastCompiler'; 3 | 4 | var ShaderGeneratorShadowCast = function() { 5 | ShaderGenerator.apply(this, arguments); 6 | this.setShaderCompiler(ShadowCompiler); 7 | }; 8 | 9 | ShaderGeneratorShadowCast.prototype = ShaderGenerator.prototype; 10 | 11 | export default ShaderGeneratorShadowCast; 12 | -------------------------------------------------------------------------------- /sources/osgShadow/osgShadow.js: -------------------------------------------------------------------------------- 1 | import ShadowCastAttribute from 'osgShadow/ShadowCastAttribute'; 2 | import ShadowCastCompiler from 'osgShadow/ShadowCastCompiler'; 3 | import ShadowCastShaderGenerator from 'osgShadow/ShadowCastShaderGenerator'; 4 | import ShadowCasterVisitor from 'osgShadow/ShadowCasterVisitor'; 5 | import ShadowFrustumIntersection from 'osgShadow/ShadowFrustumIntersection'; 6 | import ShadowMap from 'osgShadow/ShadowMap'; 7 | import ShadowMapAtlas from 'osgShadow/ShadowMapAtlas'; 8 | import ShadowReceiveAttribute from 'osgShadow/ShadowReceiveAttribute'; 9 | import ShadowSettings from 'osgShadow/ShadowSettings'; 10 | import ShadowTechnique from 'osgShadow/ShadowTechnique'; 11 | import ShadowTexture from 'osgShadow/ShadowTexture'; 12 | import ShadowTextureAtlas from 'osgShadow/ShadowTextureAtlas'; 13 | import ShadowedScene from 'osgShadow/ShadowedScene'; 14 | 15 | var osgShadow = {}; 16 | 17 | osgShadow.ShadowCastAttribute = ShadowCastAttribute; 18 | osgShadow.ShadowCastCompiler = ShadowCastCompiler; 19 | osgShadow.ShadowReceiveAttribute = ShadowReceiveAttribute; 20 | osgShadow.ShadowCasterVisitor = ShadowCasterVisitor; 21 | osgShadow.ShadowFrustumIntersection = ShadowFrustumIntersection; 22 | osgShadow.ShadowMap = ShadowMap; 23 | osgShadow.ShadowMapAtlas = ShadowMapAtlas; 24 | osgShadow.ShadowedScene = ShadowedScene; 25 | osgShadow.ShadowSettings = ShadowSettings; 26 | osgShadow.ShadowCastShaderGenerator = ShadowCastShaderGenerator; 27 | osgShadow.ShadowTechnique = ShadowTechnique; 28 | osgShadow.ShadowTexture = ShadowTexture; 29 | osgShadow.ShadowTextureAtlas = ShadowTextureAtlas; 30 | 31 | export default osgShadow; 32 | -------------------------------------------------------------------------------- /sources/osgShadow/shaderLib.js: -------------------------------------------------------------------------------- 1 | import shadowCast from 'osgShadow/shaders/shadowCast.glsl'; 2 | import shadowReceive from 'osgShadow/shaders/shadowReceive.glsl'; 3 | import shadowLinearSoft from 'osgShadow/shaders/shadowLinearSoft.glsl'; 4 | import floatFromTex from 'osgShadow/shaders/floatFromTex.glsl'; 5 | import tapPCF from 'osgShadow/shaders/tapPCF.glsl'; 6 | 7 | export default { 8 | 'shadowCast.glsl': shadowCast, 9 | 'shadowReceive.glsl': shadowReceive, 10 | 'shadowLinearSoft.glsl': shadowLinearSoft, 11 | 'floatFromTex.glsl': floatFromTex, 12 | 'tapPCF.glsl': tapPCF 13 | }; 14 | -------------------------------------------------------------------------------- /sources/osgShadow/shaders/floatFromTex.glsl: -------------------------------------------------------------------------------- 1 | #pragma include "colorEncode.glsl" 2 | 3 | // end Float codec 4 | float getSingleFloatFromTex(const in sampler2D depths, const in vec2 uv){ 5 | #ifndef _FLOATTEX 6 | return decodeFloatRGBA(texture2D(depths, uv)); 7 | #else 8 | return texture2D(depths, uv).x; 9 | #endif 10 | } 11 | 12 | vec2 getDoubleFloatFromTex(const in sampler2D depths, const in vec2 uv){ 13 | #ifndef _FLOATTEX 14 | return decodeHalfFloatRGBA(texture2D(depths, uv)); 15 | #else 16 | return texture2D(depths, uv).xy; 17 | #endif 18 | } 19 | 20 | vec4 getQuadFloatFromTex(const in sampler2D depths, const in vec2 uv){ 21 | return texture2D(depths, uv).xyzw; 22 | } 23 | // end Float codec 24 | -------------------------------------------------------------------------------- /sources/osgShadow/shaders/shadowCast.glsl: -------------------------------------------------------------------------------- 1 | #pragma include "colorEncode.glsl" 2 | 3 | #pragma DECLARE_FUNCTION 4 | vec4 shadowCast(const in vec4 fragEye, const in vec2 shadowDepthRange){ 5 | // distance to camera (we make sure we are near 0 and in [0,1]) 6 | float depth = (-fragEye.z * fragEye.w - shadowDepthRange.x) / (shadowDepthRange.y - shadowDepthRange.x); 7 | 8 | #ifdef _FLOATTEX 9 | return vec4(depth, 0.0, 0.0, 1.0); 10 | #else 11 | return encodeFloatRGBA(depth); 12 | #endif 13 | } 14 | -------------------------------------------------------------------------------- /sources/osgStats/Graph.js: -------------------------------------------------------------------------------- 1 | var Graph = function() { 2 | this._values = new Float32Array(Graph.maxGraphValue); 3 | this._index = 0; 4 | this._maxValue = 0.0; 5 | this._x = 0; 6 | this._y = 0; 7 | }; 8 | Graph.maxGraphValue = 120; 9 | Graph.prototype = { 10 | getIndex: function() { 11 | return this._index; 12 | }, 13 | getValues: function() { 14 | return this._values; 15 | }, 16 | setDisplayPosition: function(x, y) { 17 | this._x = x; 18 | this._y = y; 19 | }, 20 | getX: function() { 21 | return this._x; 22 | }, 23 | getY: function() { 24 | return this._y; 25 | }, 26 | addValue: function(value, uvColor) { 27 | var index = this._index; 28 | this._maxValue = value > this._maxValue ? value : this._maxValue; 29 | this._maxValue *= 0.99; 30 | this._values[index] = value / (this._maxValue * 1.1); 31 | if (uvColor) this._values[index] += uvColor; 32 | this._index = (this._index + 1) % Graph.maxGraphValue; 33 | } 34 | }; 35 | 36 | export default Graph; 37 | -------------------------------------------------------------------------------- /sources/osgStats/browserStats.js: -------------------------------------------------------------------------------- 1 | import notify from 'osg/notify'; 2 | 3 | var memory = undefined; 4 | 5 | var log1024 = Math.log(1024); 6 | var size = function(v) { 7 | var precision = 100; //Math.pow(10, 2); 8 | var i = Math.floor(Math.log(v) / log1024); 9 | if (v === 0) i = 1; 10 | return Math.round(v * precision / Math.pow(1024, i)) / precision; // + ' ' + sizes[i]; 11 | }; 12 | 13 | var init = function() { 14 | if (window.performance && window.performance.memory) memory = window.performance.memory; 15 | if (!memory || memory.totalJSHeapSize === 0) { 16 | notify.warn('Stats will not report memory, not supported by your browse'); 17 | } 18 | return !!memory; 19 | }; 20 | 21 | var update = function(stats) { 22 | var usedJSHeapSize = 0; 23 | var totalJSHeapSize = 0; 24 | if (memory) { 25 | usedJSHeapSize = size(memory.usedJSHeapSize); 26 | totalJSHeapSize = size(memory.totalJSHeapSize); 27 | } 28 | stats.getCounter('browserMemory').set(usedJSHeapSize); 29 | stats.getCounter('browserMemoryTotal').set(totalJSHeapSize); 30 | }; 31 | 32 | var config = { 33 | values: { 34 | browserMemory: { 35 | caption: 'Used Memory', 36 | average: true, 37 | avgMs: 1000 38 | }, 39 | browserMemoryTotal: { 40 | caption: 'Total Memory' 41 | } 42 | }, 43 | groups: [ 44 | { 45 | name: 'browser', 46 | caption: 'Browser', 47 | values: ['browserMemory', 'browserMemoryTotal'] 48 | } 49 | ], 50 | update: update, 51 | init: init 52 | }; 53 | 54 | export default config; 55 | -------------------------------------------------------------------------------- /sources/osgStats/osgStats.js: -------------------------------------------------------------------------------- 1 | import Stats from 'osgStats/Stats'; 2 | import BufferStats from 'osgStats/BufferStats'; 3 | import Graph from 'osgStats/Graph'; 4 | import TextGenerator from 'osgStats/TextGenerator'; 5 | import Counter from 'osgStats/Counter'; 6 | import defaultStats from 'osgStats/defaultStats'; 7 | import browserStats from 'osgStats/browserStats'; 8 | import glStats from 'osgStats/glStats'; 9 | 10 | var osgStats = { 11 | Stats: Stats, 12 | BufferStats: BufferStats, 13 | Graph: Graph, 14 | TextGenerator: TextGenerator, 15 | Counter: Counter, 16 | defaultStats: defaultStats, 17 | browserStats: browserStats, 18 | glStats: glStats 19 | }; 20 | 21 | export default osgStats; 22 | -------------------------------------------------------------------------------- /sources/osgText/osgText.js: -------------------------------------------------------------------------------- 1 | import Text from 'osgText/Text'; 2 | 3 | var osgText = {}; 4 | osgText.Text = Text; 5 | 6 | export default osgText; 7 | -------------------------------------------------------------------------------- /sources/osgUtil/Intersector.js: -------------------------------------------------------------------------------- 1 | import intersectionEnums from 'osgUtil/intersectionEnums'; 2 | 3 | var Intersector = function() { 4 | this._intersections = []; 5 | this._primitiveMask = intersectionEnums.ALL_PRIMITIVES; 6 | this._intersectionLimit = intersectionEnums.NO_LIMIT; 7 | }; 8 | 9 | Intersector.prototype = { 10 | reset: function() { 11 | this._intersections.length = 0; 12 | }, 13 | 14 | enter: function(node) { 15 | if (this.reachedLimit()) return false; 16 | return !node.isCullingActive() || this.intersectNode(node); 17 | }, 18 | 19 | intersectNode: function(node) { 20 | return ( 21 | this.intersectBoundingSphere(node.getBoundingSphere()) || 22 | this.intersectBoundingBox(node.getBoundingBox()) 23 | ); 24 | }, 25 | 26 | intersectBoundingSphere: function(/*bsphere*/) { 27 | return false; 28 | }, 29 | 30 | intersectBoundingBox: function(/*bsphere*/) { 31 | return false; 32 | }, 33 | 34 | getIntersections: function() { 35 | return this._intersections; 36 | }, 37 | 38 | setIntersectionLimit: function(limit) { 39 | this._intersectionLimit = limit; 40 | }, 41 | 42 | getIntersectionLimit: function() { 43 | return this._intersectionLimit; 44 | }, 45 | 46 | setPrimitiveMask: function(primitiveMask) { 47 | this._primitiveMask = primitiveMask; 48 | }, 49 | 50 | getPrimitiveMask: function() { 51 | return this._primitiveMask; 52 | }, 53 | 54 | reachedLimit: function() { 55 | return ( 56 | this._intersectionLimit === intersectionEnums.LIMIT_ONE && 57 | this._intersections.length > 0 58 | ); 59 | }, 60 | 61 | setCurrentTransformation: function(/*matrix*/) {}, 62 | 63 | intersect: function(/*iv, node*/) {} 64 | }; 65 | 66 | export default Intersector; 67 | -------------------------------------------------------------------------------- /sources/osgUtil/intersectionEnums.js: -------------------------------------------------------------------------------- 1 | export default { 2 | NO_LIMIT: 0, 3 | LIMIT_ONE_PER_DRAWABLE: 1, 4 | LIMIT_ONE: 2, 5 | 6 | // PrimitiveMask 7 | POINT_PRIMITIVES: 1 << 0, /// check for points 8 | LINE_PRIMITIVES: 1 << 1, /// check for lines 9 | TRIANGLE_PRIMITIVES: 1 << 2, /// check for triangles and other primitives like quad, polygons that can be decomposed into triangles 10 | ALL_PRIMITIVES: (1 << 0) | (1 << 1) | (1 << 2) 11 | }; 12 | -------------------------------------------------------------------------------- /sources/osgViewer/Scene.js: -------------------------------------------------------------------------------- 1 | import utils from 'osg/utils'; 2 | import Object from 'osg/Object'; 3 | import DatabasePager from 'osgDB/DatabasePager'; 4 | 5 | var Scene = function() { 6 | Object.call(this); 7 | this._databasePager = new DatabasePager(); 8 | this._sceneData = undefined; 9 | }; 10 | 11 | utils.createPrototypeObject( 12 | Scene, 13 | utils.objectInherit(Object.prototype, { 14 | getSceneData: function() { 15 | return this._sceneData; 16 | }, 17 | 18 | setSceneData: function(node) { 19 | this._sceneData = node; 20 | }, 21 | 22 | setDatabasePager: function(dbpager) { 23 | this._databasePager = dbpager; 24 | }, 25 | 26 | getDatabasePager: function() { 27 | return this._databasePager; 28 | }, 29 | 30 | // database pager are not implemented yet here 31 | updateSceneGraph: function(updateVisitor) { 32 | if (this._databasePager) 33 | this._databasePager.updateSceneGraph(updateVisitor.getFrameStamp()); 34 | if (this._sceneData) this._sceneData.accept(updateVisitor); 35 | } 36 | }), 37 | 'osgViewer', 38 | 'Scene' 39 | ); 40 | 41 | export default Scene; 42 | -------------------------------------------------------------------------------- /sources/osgViewer/input/InputConstants.js: -------------------------------------------------------------------------------- 1 | var InputGroups = {}; 2 | 3 | InputGroups.SCENE = 'scene'; 4 | 5 | InputGroups.MANIPULATORS = 'scene.manipulators'; 6 | 7 | InputGroups.ORBIT_MANIPULATOR = 'scene.manipulators.orbit'; 8 | InputGroups.ORBIT_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.orbit.mousekeyboard'; 9 | InputGroups.ORBIT_MANIPULATOR_RESETTOHOME = 'scene.manipulators.orbit.mousekeyboard.home'; 10 | InputGroups.ORBIT_MANIPULATOR_TOUCH = 'scene.manipulators.orbit.touch'; 11 | InputGroups.ORBIT_MANIPULATOR_WEBVR = 'scene.manipulators.orbit.webvr'; 12 | InputGroups.ORBIT_MANIPULATOR_DEVICEORIENTATION = 'scene.manipulators.orbit.deviceorientation'; 13 | InputGroups.ORBIT_MANIPULATOR_GAMEPAD = 'scene.manipulators.orbit.gamepad'; 14 | 15 | InputGroups.FPS_MANIPULATOR = 'scene.manipulators.fps'; 16 | InputGroups.FPS_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.fps.mousekeyboard'; 17 | InputGroups.FPS_MANIPULATOR_RESETTOHOME = 'scene.manipulators.fps.mousekeyboard.home'; 18 | InputGroups.FPS_MANIPULATOR_TOUCH = 'scene.manipulators.fps.touch'; 19 | InputGroups.FPS_MANIPULATOR_WEBVR = 'scene.manipulators.fps.webvr'; 20 | InputGroups.FPS_MANIPULATOR_DEVICEORIENTATION = 'scene.manipulators.fps.deviceorientation'; 21 | InputGroups.FPS_MANIPULATOR_GAMEPAD = 'scene.manipulators.fps.gamepad'; 22 | 23 | InputGroups.CAD_MANIPULATOR = 'scene.manipulators.cad'; 24 | InputGroups.CAD_MANIPULATOR_MOUSEKEYBOARD = 'scene.manipulators.cad.mousekeyboard'; 25 | InputGroups.CAD_MANIPULATOR_RESETTOHOME = 'scene.manipulators.cad.mousekeyboard.home'; 26 | InputGroups.CAD_MANIPULATOR_TOUCH = 'scene.manipulators.cad.touch'; 27 | 28 | InputGroups.NODE_GIZMO = 'scene.nodegizmo'; 29 | 30 | InputGroups.UI = 'ui'; 31 | InputGroups.STATS = 'ui.stats'; 32 | 33 | export default InputGroups; 34 | -------------------------------------------------------------------------------- /sources/osgViewer/input/source/InputSource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Abstract InputSource 3 | * @param canvas 4 | * @constructor 5 | */ 6 | var InputSource = function(target) { 7 | this._target = target; 8 | this._supportedEvents = []; 9 | }; 10 | InputSource.prototype = { 11 | supportsEvent: function(eventName) { 12 | for (var i = 0; i < this._supportedEvents.length; i++) { 13 | var event = this._supportedEvents[i]; 14 | if (eventName.indexOf(event) === 0) { 15 | return true; 16 | } 17 | } 18 | return false; 19 | }, 20 | 21 | setInputManager: function(inputManager) { 22 | this._inputManager = inputManager; 23 | } 24 | }; 25 | 26 | export default InputSource; 27 | -------------------------------------------------------------------------------- /sources/osgViewer/osgViewer.js: -------------------------------------------------------------------------------- 1 | import Renderer from 'osgViewer/Renderer'; 2 | import View from 'osgViewer/View'; 3 | import Viewer from 'osgViewer/Viewer'; 4 | import Scene from 'osgViewer/Scene'; 5 | import InputGroups from 'osgViewer/input/InputConstants'; 6 | 7 | var osgViewer = {}; 8 | 9 | osgViewer.Renderer = Renderer; 10 | osgViewer.View = View; 11 | osgViewer.Viewer = Viewer; 12 | osgViewer.Scene = Scene; 13 | osgViewer.InputGroups = InputGroups; 14 | 15 | export default osgViewer; 16 | -------------------------------------------------------------------------------- /sources/osgWrappers/osgWrappers.js: -------------------------------------------------------------------------------- 1 | import osg from 'osgWrappers/serializers/osg'; 2 | import osgAnimation from 'osgWrappers/serializers/osgAnimation'; 3 | import osgText from 'osgWrappers/serializers/osgText'; 4 | 5 | var osgWrappers = {}; 6 | 7 | osgWrappers.osg = osg; 8 | osgWrappers.osgAnimation = osgAnimation; 9 | osgWrappers.osgText = osgText; 10 | 11 | export default osgWrappers; 12 | -------------------------------------------------------------------------------- /sources/osgWrappers/serializers/osgText.js: -------------------------------------------------------------------------------- 1 | import P from 'bluebird'; 2 | import osgWrapper from 'osgWrappers/serializers/osg'; 3 | import notify from 'osg/notify'; 4 | import Text from 'osgText/Text'; 5 | 6 | var osgTextWrapper = {}; 7 | 8 | osgTextWrapper.Text = function(input, node) { 9 | var jsonObj = input.getJSON(); 10 | if (!jsonObj.Text) return P.reject(); 11 | 12 | var promise = osgWrapper.Node(input, node); 13 | node.setColor(jsonObj.Color); 14 | node.setText(jsonObj.Text); 15 | node.setAutoRotateToScreen(jsonObj.AutoRotateToScreen); 16 | node.setPosition(jsonObj.Position); 17 | node.setCharacterSize(jsonObj.CharacterSize); 18 | 19 | if (jsonObj.Layout === 'VERTICAL') { 20 | notify.error('Vertical Alignment not supported'); 21 | return P.reject(); 22 | } 23 | var alignment = jsonObj.Alignment; 24 | if (jsonObj.Alignment.indexOf('BASE_LINE') > -1) { 25 | if (jsonObj.Alignment === 'LEFT_BASE_LINE') { 26 | alignment = Text.LEFT_CENTER; 27 | } else if (jsonObj.Alignment === 'CENTER_BASE_LINE') { 28 | alignment = Text.CENTER_CENTER; 29 | } else if (jsonObj.Alignment === 'RIGHT_BASE_LINE') { 30 | alignment = Text.RIGHT_CENTER; 31 | } else if (jsonObj.Alignment === 'LEFT_BOTTOM_BASE_LINE') { 32 | alignment = Text.LEFT_BOTTOM; 33 | } else if (jsonObj.Alignment === 'CENTER_BOTTOM_BASE_LINE') { 34 | alignment = Text.CENTER_BOTTOM; 35 | } else if (jsonObj.Alignment === 'RIGHT_BOTTOM_BASE_LINE') { 36 | alignment = Text.RIGHT_BOTTOM; 37 | } 38 | /*develblock:start*/ 39 | notify.log('Base line alignments not supported, alignment converted'); 40 | /*develblock:end*/ 41 | } 42 | node.setAlignment(alignment); 43 | node.setLayout(jsonObj.Layout); 44 | 45 | return promise; 46 | }; 47 | 48 | export default osgTextWrapper; 49 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mocha 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/mockup/greyscale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/tests/mockup/greyscale.png -------------------------------------------------------------------------------- /tests/mockup/multistream.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/tests/mockup/multistream.bin -------------------------------------------------------------------------------- /tests/mockup/rgb24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/tests/mockup/rgb24.png -------------------------------------------------------------------------------- /tests/mockup/rgba32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/tests/mockup/rgba32.png -------------------------------------------------------------------------------- /tests/mockup/stream.bin: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /tests/osg/BlendColor.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import mockup from 'tests/mockup/mockup'; 3 | import BlendColor from 'osg/BlendColor'; 4 | import State from 'osg/State'; 5 | import ShaderGeneratorProxy from 'osgShader/ShaderGeneratorProxy'; 6 | 7 | export default function() { 8 | test('BlendColor', function() { 9 | var n = new BlendColor(); 10 | assert.isOk( 11 | n.getConstantColor()[0] === 1.0 && 12 | n.getConstantColor()[1] === 1.0 && 13 | n.getConstantColor()[2] === 1.0 && 14 | n.getConstantColor()[3] === 1.0, 15 | 'Check default constantColor' 16 | ); 17 | 18 | n.setConstantColor([0, 0.5, 0, 0.5]); 19 | assert.isOk( 20 | n.getConstantColor()[0] === 0.0 && 21 | n.getConstantColor()[1] === 0.5 && 22 | n.getConstantColor()[2] === 0.0 && 23 | n.getConstantColor()[3] === 0.5, 24 | 'Check set constant color' 25 | ); 26 | 27 | var state = new State(new ShaderGeneratorProxy()); 28 | state.setGraphicContext(mockup.createFakeRenderer()); 29 | 30 | n.apply(state); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /tests/osg/BufferArray.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import mockup from 'tests/mockup/mockup'; 3 | import BufferArray from 'osg/BufferArray'; 4 | 5 | export default function() { 6 | test('BufferArray', function() { 7 | (function() { 8 | var gl = mockup.createFakeRenderer(); 9 | gl.createBuffer = function() { 10 | return {}; 11 | }; 12 | 13 | var content = []; 14 | for (var i = 0, l = 3 * 50; i < l; i++) { 15 | content.push(i); 16 | } 17 | var b = new BufferArray(BufferArray.ARRAY_BUFFER, content, 3); 18 | b.bind(gl); 19 | assert.isOk(b._buffer !== undefined, 'Check we created gl buffer'); 20 | b.releaseGLObjects(); 21 | assert.isOk(b._buffer === undefined, 'Check we released gl buffer'); 22 | 23 | assert.equal(b.getType(), 0x1406, 'Check the type set is float 32'); 24 | assert.equal(b.getItemSize(), 3, 'Check item size is 3'); 25 | })(); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /tests/osg/BufferArrayProxy.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import BufferArrayProxy from 'osg/BufferArrayProxy'; 3 | import BufferArray from 'osg/BufferArray'; 4 | 5 | export default function() { 6 | test('BufferArrayProxy', function() { 7 | (function() { 8 | var bufferArrayA = new BufferArray(); 9 | var bufferArrayB = new BufferArray(); 10 | 11 | var bufferArrayProxyA = new BufferArrayProxy(bufferArrayA); 12 | var bufferArrayProxyB = new BufferArrayProxy(bufferArrayB); 13 | 14 | bufferArrayProxyA.setBufferArray(bufferArrayB); 15 | bufferArrayProxyB.setBufferArray(bufferArrayA); 16 | 17 | assert.equal( 18 | bufferArrayProxyA.getInstanceID(), 19 | bufferArrayB.getInstanceID(), 20 | 'check proxyA use B' 21 | ); 22 | assert.equal( 23 | bufferArrayProxyB.getInstanceID(), 24 | bufferArrayA.getInstanceID(), 25 | 'check proxyB use A' 26 | ); 27 | assert.equal( 28 | bufferArrayProxyA.getInitialBufferArray().getInstanceID(), 29 | bufferArrayA.getInstanceID(), 30 | 'check initial buffer' 31 | ); 32 | 33 | bufferArrayProxyA.setBufferArray(bufferArrayProxyB); 34 | assert.equal( 35 | bufferArrayProxyA.getInstanceID(), 36 | bufferArrayProxyB.getBufferArray().getInstanceID(), 37 | 'check proxy with proxy' 38 | ); 39 | })(); 40 | }); 41 | } 42 | -------------------------------------------------------------------------------- /tests/osg/CullFace.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import mockup from 'tests/mockup/mockup'; 3 | import CullFace from 'osg/CullFace'; 4 | import State from 'osg/State'; 5 | import ShaderGeneratorProxy from 'osgShader/ShaderGeneratorProxy'; 6 | 7 | export default function() { 8 | test('CullFace', function() { 9 | var n = new CullFace(); 10 | assert.isOk(n.getMode() === CullFace.BACK, 'Check default mode'); 11 | 12 | var state = new State(new ShaderGeneratorProxy()); 13 | state.setGraphicContext(mockup.createFakeRenderer()); 14 | 15 | n.apply(state); 16 | 17 | n = new CullFace(CullFace.DISABLE); 18 | n.apply(state); 19 | 20 | var n2 = new CullFace('FRONT'); 21 | assert.isOk(n2.getMode() === CullFace.FRONT, 'Check string parameter'); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/osg/Depth.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import mockup from 'tests/mockup/mockup'; 3 | import Depth from 'osg/Depth'; 4 | import State from 'osg/State'; 5 | import ShaderGeneratorProxy from 'osgShader/ShaderGeneratorProxy'; 6 | 7 | export default function() { 8 | test('Depth', function() { 9 | var n = new Depth(); 10 | assert.isOk(n._near === 0.0, 'Check near'); 11 | assert.isOk(n._far === 1.0, 'Check far'); 12 | assert.isOk(n._func === Depth.LESS, 'Check function'); 13 | assert.isOk(n._writeMask === true, 'Check write mask'); 14 | 15 | var state = new State(new ShaderGeneratorProxy()); 16 | state.setGraphicContext(mockup.createFakeRenderer()); 17 | 18 | n.apply(state); 19 | 20 | n = new Depth(Depth.DISABLE); 21 | n.apply(state); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/osg/Image.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import Image from 'osg/Image'; 3 | import mockup from 'tests/mockup/mockup'; 4 | 5 | export default function() { 6 | test('Image.isGreyScale grey image', function(done) { 7 | var test = function(img) { 8 | var n = new Image(img); 9 | 10 | assert.equal(n.isGreyscale(2), true, 'check image is grey'); 11 | done(); 12 | }; 13 | 14 | var img = new window.Image(); 15 | img.onload = function() { 16 | test(this); 17 | }; 18 | 19 | img.src = 'mockup/greyscale.png'; 20 | 21 | if (mockup.isNodeContext()) { 22 | img.onload(); 23 | } 24 | }); 25 | 26 | test('Image.isGreyScale color image', function(done) { 27 | var test = function(img) { 28 | var n = new Image(img); 29 | 30 | assert.equal(n.isGreyscale(2), false, 'check image is not grey'); 31 | done(); 32 | }; 33 | 34 | var img = new window.Image(); 35 | img.onload = function() { 36 | test(this); 37 | }; 38 | img.src = 'mockup/rgba32.png'; 39 | if (mockup.isNodeContext()) { 40 | img.onload(); 41 | } 42 | }); 43 | 44 | test('Image.isReady', function() { 45 | var fakeImage = { 46 | complete: true, 47 | naturalWidth: 1024, 48 | isReady: function() { 49 | return true; 50 | } 51 | }; 52 | var n = new Image(fakeImage); 53 | assert.isOk(n.isReady(), 'check wrapped HTML Image '); 54 | }); 55 | } 56 | -------------------------------------------------------------------------------- /tests/osg/PagedLOD.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import 'tests/mockup/mockup'; 3 | import Node from 'osg/Node'; 4 | import Lod from 'osg/Lod'; 5 | import PagedLOD from 'osg/PagedLOD'; 6 | import Shape from 'osg/shape'; 7 | 8 | export default function() { 9 | test('PagedLOD', function() { 10 | var plod = new PagedLOD(); 11 | assert.isOk(plod.children.length === 0, 'number of children must be 0'); 12 | assert.isOk(plod.getParents().length === 0, 'number of parents must be 0'); 13 | var n = new Node(); 14 | plod.addChild(n, 0, 200); 15 | assert.isOk(plod.children.length === 1, 'number of children must be 1'); 16 | assert.isOk(plod._range[0][0] === 0, 'range min should be 0'); 17 | assert.isOk(plod._range[0][1] === 200, ' range max should be 200'); 18 | }); 19 | 20 | test('PagedLOD.UserDefinedBound', function() { 21 | var plod = new PagedLOD(); 22 | // Create a quad of 2x2 with center in 0,0,0 23 | 24 | var n = Shape.createTexturedQuadGeometry(-1, -1, 0, 2, 0, 0, 0, 2, 0); 25 | plod.setRange(0, 0, 200); 26 | plod.addChildNode(n); 27 | console.log(plod.getBound().radius()); 28 | assert.equalVector(plod.getBound().radius(), 1.4142135623730951, 0.0000001); 29 | // Set a USER_DEFINED_CENTER/radius and try again 30 | plod.setCenter([0, 0, 0]); 31 | plod.setRadius(10.0); 32 | plod.dirtyBound(); 33 | assert.equalVector(plod.getBound().radius(), 10.0, 0.0000001); 34 | // Now test UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED 35 | plod.setCenterMode(Lod.UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED); 36 | // move the center, so the user defined bs does not contain the default bs 37 | plod.setCenter([10, 10, 10]); 38 | plod.dirtyBound(); 39 | assert.equalVector(plod.getBound().radius(), 14.367360819, 0.0000001); 40 | }); 41 | } 42 | -------------------------------------------------------------------------------- /tests/osg/Plane.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import BoundingSphere from 'osg/BoundingSphere'; 3 | import Plane from 'osg/Plane'; 4 | 5 | export default function() { 6 | test('Plane', function() { 7 | var p = Plane.create(); 8 | Plane.setNormal(p, [2, 0, 0]); 9 | Plane.setDistance(p, -2); 10 | Plane.normalizeEquation(p); 11 | 12 | assert.isOk(Plane.distanceToPlane(p, [4, 0, 0]) === 3); 13 | assert.isOk(Plane.distanceToPlane(p, [-4, 0, 0]) === -5); 14 | assert.isOk(Plane.distanceToPlane(p, [1, 0, 0]) === 0); 15 | 16 | var bSphere = new BoundingSphere(); 17 | bSphere.set([-40, 0, 0], 0.1); 18 | bSphere.expandByVec3([-0.1, -0.1, 0.0]); 19 | 20 | assert.isOk(Plane.intersectsOrContainsBoundingSphere(p, bSphere) === Plane.OUTSIDE); 21 | bSphere.expandByVec3([1.0, 4.0, 0.0]); 22 | bSphere.expandByVec3([2.0, 3.0, 0.0]); 23 | 24 | assert.isOk(Plane.intersectsOrContainsBoundingSphere(p, bSphere) === Plane.INTERSECT); 25 | bSphere.set([40, 0, 0], 1.0); 26 | assert.isOk(Plane.intersectsOrContainsBoundingSphere(p, bSphere) === Plane.INSIDE); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /tests/osg/Switch.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import 'tests/mockup/mockup'; 3 | import Node from 'osg/Node'; 4 | import NodeVisitor from 'osg/NodeVisitor'; 5 | import Switch from 'osg/Switch'; 6 | import Utils from 'osg/utils'; 7 | 8 | export default function() { 9 | test('Switch', function() { 10 | var switchNode = new Switch(); 11 | assert.isOk(switchNode.children.length === 0, 'number of children must be 0'); 12 | assert.isOk(switchNode.getParents().length === 0, 'number of parents must be 0'); 13 | var enabledChild = new Node(); 14 | enabledChild.setName('enabled'); 15 | switchNode.addChild(enabledChild, true); 16 | var disabledChild = new Node(); 17 | disabledChild.setName('disabled'); 18 | switchNode.addChild(disabledChild, false); 19 | assert.isOk(switchNode.children.length === 2, 'number of children must be 2'); 20 | assert.isOk(switchNode._values[0] === true, 'first value should be true'); 21 | assert.isOk(switchNode._values[1] === false, 'first value should be false'); 22 | 23 | var TestVisitor = function() { 24 | NodeVisitor.call(this, NodeVisitor.TRAVERSE_ACTIVE_CHILDREN); 25 | }; 26 | 27 | TestVisitor.prototype = Utils.objectInherit(NodeVisitor.prototype, { 28 | apply: function(node) { 29 | if (node.getName !== undefined) { 30 | assert.isOk( 31 | node.getName() !== 'disabled', 32 | 'only enabled child should be traversed' 33 | ); 34 | } 35 | this.traverse(node); 36 | } 37 | }); 38 | 39 | var testVisitor = new TestVisitor(); 40 | testVisitor.apply(switchNode); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /tests/osg/Uniform.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import Uniform from 'osg/Uniform'; 3 | 4 | export default function() { 5 | test('Uniform', function() { 6 | (function() { 7 | var testInt = Uniform.createInt1(12, 'int_uniform'); 8 | var testFloat = Uniform.createFloat1(6.283, 'float_uniform'); 9 | var testVec3 = Uniform.createFloat3([3.14, 6.28, 1.44], 'vec3_uniform'); 10 | var testFloatArray = Uniform.createFloat1( 11 | new Float32Array([42.314]), 12 | 'float_array_uniform' 13 | ); 14 | var testIntArray = Uniform.createInt1(new Int32Array([1234]), 'int_array_uniform'); 15 | 16 | assert.isOk(Uniform.isUniform(testInt) === true, 'is uniform'); 17 | assert.isOk(Uniform.isUniform(testFloat) === true, 'is uniform'); 18 | assert.isOk(Uniform.isUniform(testVec3) === true, 'is uniform'); 19 | assert.isOk(Uniform.isUniform(testFloatArray) === true, 'is uniform'); 20 | assert.isOk(Uniform.isUniform(testIntArray) === true, 'is uniform'); 21 | assert.isOk(Uniform.isUniform('text') === false, 'is not uniform'); 22 | assert.isOk(Uniform.isUniform(65) === false, 'is not uniform'); 23 | })(); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /tests/osg/WebGLCaps.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import Texture from 'osg/Texture'; 3 | import WebGLCaps from 'osg/WebGLCaps'; 4 | import mockup from 'tests/mockup/mockup'; 5 | 6 | export default function() { 7 | test('WebGLCaps', function() { 8 | var canvas = mockup.createCanvas(true); 9 | var gl = canvas.getContext(); 10 | var webglCaps = WebGLCaps.instance(gl); 11 | 12 | webglCaps.getWebGLExtensions().OES_texture_float = true; // eslint-disable-line 13 | webglCaps._checkRTT[Texture.FLOAT + ',' + Texture.NEAREST] = true; 14 | 15 | var hFloat = webglCaps.hasFloatRTT(gl); 16 | assert.isOk(hFloat, 'float detect'); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /tests/osgAnimation/osgAnimationTests.js: -------------------------------------------------------------------------------- 1 | import BasicAnimationManager from 'tests/osgAnimation/BasicAnimationManager'; 2 | import Interpolator from 'tests/osgAnimation/Interpolator'; 3 | import StackedTransform from 'tests/osgAnimation/StackedTransform'; 4 | 5 | export default function() { 6 | BasicAnimationManager(); 7 | Interpolator(); 8 | StackedTransform(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/osgDB/osgDBTests.js: -------------------------------------------------------------------------------- 1 | import Input from 'tests/osgDB/Input'; 2 | import ReaderParser from 'tests/osgDB/ReaderParser'; 3 | import DatabasePager from 'tests/osgDB/DatabasePager'; 4 | 5 | export default function() { 6 | Input(); 7 | ReaderParser(); 8 | DatabasePager(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/osgGA/osgGATests.js: -------------------------------------------------------------------------------- 1 | import FirstPersonManipulator from 'tests/osgGA/FirstPersonManipulator'; 2 | import OrbitManipulator from 'tests/osgGA/OrbitManipulator'; 3 | 4 | export default function() { 5 | FirstPersonManipulator(); 6 | OrbitManipulator(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/osgShader/osgShaderTests.js: -------------------------------------------------------------------------------- 1 | import Compiler from 'tests/osgShader/Compiler'; 2 | import ShaderGenerator from 'tests/osgShader/ShaderGenerator'; 3 | 4 | export default function() { 5 | Compiler(); 6 | ShaderGenerator(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/osgShadow/osgShadowTests.js: -------------------------------------------------------------------------------- 1 | import ShadowMap from 'tests/osgShadow/ShadowMap'; 2 | import ShadowedScene from 'tests/osgShadow/ShadowedScene'; 3 | 4 | export default function() { 5 | ShadowMap(); 6 | ShadowedScene(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/osgText/Text.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import osgText from 'osgText/Text'; 3 | 4 | export default function() { 5 | test('Text._nextPowerOfTwo', function() { 6 | var text = new osgText(); 7 | var npot = text._nextPowerOfTwo(25); 8 | assert.isOk(npot === 32, 'next power of two must be 32'); 9 | npot = text._nextPowerOfTwo(16); 10 | assert.isOk(npot === 16, 'next power of two must be 16'); 11 | npot = text._nextPowerOfTwo(129); 12 | assert.isOk(npot === 256, 'next power of two must be 256'); 13 | npot = text._nextPowerOfTwo(2031); 14 | assert.isOk(npot === 2048, 'next power of two must be 256'); 15 | }); 16 | 17 | test('Text.setAlignment', function() { 18 | var text = new osgText('test'); 19 | text.setAlignment(osgText.LEFT_CENTER); 20 | // we need to call to draw text as the values are updated next frame, so we emulate it just to test. 21 | text.drawText(); 22 | assert.isOk(text._context.textAlign === 'left', 'context align should be left'); 23 | assert.isOk(text._textX === 0, '_textX should be 0'); 24 | assert.isOk(text._context.textBaseline === 'middle', 'context baseline should be middle'); 25 | text.setAlignment('RIGHT_TOP'); 26 | text.drawText(); 27 | assert.isOk(text._context.textAlign === 'right', 'context align should be right'); 28 | assert.isOk(text._textY === 0, '_textY should be 0'); 29 | assert.isOk(text._context.textBaseline === 'top', 'context baseline should be top'); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /tests/osgText/osgTextTests.js: -------------------------------------------------------------------------------- 1 | import Text from 'tests/osgText/Text'; 2 | 3 | export default function() { 4 | Text(); 5 | } 6 | -------------------------------------------------------------------------------- /tests/osgUtil/osgUtilTests.js: -------------------------------------------------------------------------------- 1 | import LineSegmentIntersector from 'tests/osgUtil/LineSegmentIntersector'; 2 | import LineSegmentIntersectFunctor from 'tests/osgUtil/LineSegmentIntersectFunctor'; 3 | import PolytopeIntersector from 'tests/osgUtil/PolytopeIntersector'; 4 | import IntersectionVisitor from 'tests/osgUtil/IntersectionVisitor'; 5 | import SphereIntersector from 'tests/osgUtil/SphereIntersector'; 6 | 7 | export default function() { 8 | LineSegmentIntersector(); 9 | LineSegmentIntersectFunctor(); 10 | PolytopeIntersector(); 11 | IntersectionVisitor(); 12 | SphereIntersector(); 13 | } 14 | -------------------------------------------------------------------------------- /tests/osgViewer/View.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import View from 'osgViewer/View'; 3 | import mockup from 'tests/mockup/mockup'; 4 | 5 | export default function() { 6 | test('View', function() { 7 | var gc = mockup.createFakeRenderer(); 8 | var view = new View(); 9 | view.setGraphicContext(gc); 10 | assert.isOk(view.getGraphicContext() === gc, 'Check graphic context'); 11 | 12 | assert.isOk(view.getFrameStamp() !== undefined, 'Check FrameStamp'); 13 | 14 | assert.isOk(view.getScene() !== undefined, 'Check scene'); 15 | assert.isOk(view.getSceneData() === undefined, 'Check scene data'); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /tests/osgViewer/osgViewerTests.js: -------------------------------------------------------------------------------- 1 | import View from 'tests/osgViewer/View'; 2 | import Viewer from 'tests/osgViewer/Viewer'; 3 | import Inputs from 'tests/osgViewer/Inputs'; 4 | 5 | export default function() { 6 | Inputs(); 7 | View(); 8 | Viewer(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/osgWrappers/osgWrappersTests.js: -------------------------------------------------------------------------------- 1 | import osgAnimation from 'tests/osgWrappers/osgAnimation'; 2 | 3 | export default function() { 4 | osgAnimation(); 5 | } 6 | -------------------------------------------------------------------------------- /tests/runTests.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node, mocha */ 2 | process.chdir(__dirname); 3 | require('./mockup/mockupForNode.js'); 4 | var Mocha = require('mocha'); 5 | 6 | var mocha = new Mocha({ 7 | ui: 'qunit', 8 | reporter: 'spec' 9 | }); 10 | 11 | mocha.addFile('../builds/tests/tests.js'); 12 | 13 | mocha.run().on('end', function() { 14 | // In case the file has no tests we should make mocha fail 15 | if (this.stats.tests === 0) { 16 | console.error('No tests found'); 17 | process.exit(-1); 18 | } 19 | 20 | // One ore more tests failed or skipped 21 | if (this.stats.passes < this.stats.tests) { 22 | console.error('test failed'); 23 | process.exit(-1); 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /tests/tests.js: -------------------------------------------------------------------------------- 1 | import 'OSG'; 2 | import osg from 'tests/osg/osgTests'; 3 | import osgAnimation from 'tests/osgAnimation/osgAnimationTests'; 4 | import osgDB from 'tests/osgDB/osgDBTests'; 5 | import osgGA from 'tests/osgGA/osgGATests'; 6 | import osgUtil from 'tests/osgUtil/osgUtilTests'; 7 | import osgViewer from 'tests/osgViewer/osgViewerTests'; 8 | import osgShader from 'tests/osgShader/osgShaderTests'; 9 | import osgShadow from 'tests/osgShadow/osgShadowTests'; 10 | import osgText from 'tests/osgText/osgTextTests'; 11 | import osgWrappers from 'tests/osgWrappers/osgWrappersTests'; 12 | 13 | suite('osgWrappers'); 14 | osgWrappers(); 15 | 16 | suite('osgText'); 17 | osgText(); 18 | 19 | suite('osgShadow'); 20 | osgShadow(); 21 | 22 | suite('osgShader'); 23 | osgShader(); 24 | 25 | suite('osgViewer'); 26 | osgViewer(); 27 | 28 | suite('osgUtil'); 29 | osgUtil(); 30 | 31 | suite('osgGA'); 32 | osgGA(); 33 | 34 | suite('osgDB'); 35 | osgDB(); 36 | 37 | suite('osg'); 38 | osg(); 39 | 40 | suite('osgAnimation'); 41 | osgAnimation(); 42 | -------------------------------------------------------------------------------- /website/CNAME: -------------------------------------------------------------------------------- 1 | osgjs.org 2 | -------------------------------------------------------------------------------- /website/build-wintersmith.js: -------------------------------------------------------------------------------- 1 | var wintersmith = require( 'wintersmith' ); 2 | var fs = require( 'fs' ); 3 | 4 | var buildDest = process.argv[ 2 ]; 5 | 6 | // create the sites environment, can also be called with a config object. e.g. 7 | // {contents: '/some/contents', locals: {powerLevel: 10}}, ..} 8 | var env = wintersmith( 'config.json' ); 9 | env.config.output = buildDest; 10 | //console.log( env.config ); 11 | 12 | // build site 13 | env.build( function ( error ) { 14 | if ( error ) throw error; 15 | console.log( 'Done!' ); 16 | process.exit(); 17 | } ); 18 | -------------------------------------------------------------------------------- /website/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "locals": { 3 | "title": "OSG.JS" 4 | }, 5 | "plugins": [ 6 | "wintersmith-nunjucks" 7 | ], 8 | "nunjucks": { 9 | "autoescape": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /website/contents/api-documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | url: index.html#concepts 3 | --- 4 | 5 | ### Documentation, API, Analysis 6 | 7 | 8 | OSGJS is based on [OpenSceneGraph](http://en.wikipedia.org/wiki/OpenSceneGraph) API, which itself is based on a few concepts that allow for a solid grasp around the whole library once and for all, and those are mandatory in order to dive into code. 9 | -------------------------------------------------------------------------------- /website/contents/assets/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/about.png -------------------------------------------------------------------------------- /website/contents/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/favicon.png -------------------------------------------------------------------------------- /website/contents/assets/img/animation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/animation.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/camera.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/camera.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/cubemotion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/cubemotion.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/demojs-fff.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/demojs-fff.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/dualcam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/dualcam.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/earlyz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/earlyz.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/frustum-culling.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/frustum-culling.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/gizmo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/gizmo.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/globetweeter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/globetweeter.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/hdr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/hdr.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/lights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/lights.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/materials.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/materials.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/multipleviewers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/multipleviewers.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/nouvellevague.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/nouvellevague.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/pbr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/pbr.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/performance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/performance.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/peter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/peter.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/picking.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/picking.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/plod.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/plod.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/pointcloudviz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/pointcloudviz.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/postproc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/postproc.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/scene-debug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/scene-debug.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/shader-generator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/shader-generator.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/shadowmap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/shadowmap.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/sketchfab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/sketchfab.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/sound3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/sound3d.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/ssao.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/ssao.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/terrain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/terrain.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/text2D.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/text2D.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/texture-video.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/texture-video.jpg -------------------------------------------------------------------------------- /website/contents/assets/img/veditor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/img/veditor.jpg -------------------------------------------------------------------------------- /website/contents/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cedricpinson/osgjs/d3c9a4bebeebfb891eb2d708cd0828c126aeec18/website/contents/assets/logo.png -------------------------------------------------------------------------------- /website/contents/concepts.md: -------------------------------------------------------------------------------- 1 | ## OGSJ Code Documentation 2 | [API (auto-generated)](docs/annotated-source/osg.html) | [Unit Tests (Qunit)](tests/) | [Analysis (Plato)](docs/analysis) 3 | ## Concepts 4 | ### Overall Concepts Introduction 5 | [Slides](http://www.macs.hw.ac.uk/~ruth/year4VEs/Slides10/L9.pdf) 6 | ### What is a Scene Graph are its uses ? 7 | [Scene Graph](http://www.stackedboxes.org/~lmb/en/computer-stuff/asittbpo-open-scene-graph/chapter-1-the-basics) 8 | ### How to set properties on Nodes ? 9 | [StateSet](http://www.bricoworks.com/articles/stateset/stateset.html) and [StateGraph](http://www.bricoworks.com/articles/stategraph/stategraph.html) 10 | ### Basic 11 | An interactive introduction to [WebGL](http://www.webglacademy.com/) 12 | ### OpenSceneGraph Help 13 | [FAQ](http://www.openscenegraph.org/index.php/support/faq) and [Knowledge Base](http://www.openscenegraph.org/index.php/documentation/knowledge-base) 14 | -------------------------------------------------------------------------------- /website/contents/getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | url: http://codepen.io/collection/CbvIg/ 3 | --- 4 | 5 | ### Tutorials 6 | Nothing helps more than toying with osgjs code and osg concepts directly, here's an interactive playground where you can start coding osgjs in 5 secs 7 | -------------------------------------------------------------------------------- /website/contents/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: OSG.JS - Javascript Implementation of OpenSceneGraph 3 | template: index.html 4 | github: http://github.com/cedricpinson/osgjs 5 | download: https://github.com/cedricpinson/osgjs/releases/latest 6 | --- 7 | 8 | # OSG.JS 9 | 10 | ## Create 3D web apps 11 | 12 | OSGJS is a WebGL framework based on OpenSceneGraph concepts. It allows an individual to use an "OpenSceneGraph-like" toolbox to interact with WebGL via JavaScript, and provides facilities for exporting various assets to the osgjs format. 13 | The API is kept as similar to OpenSceneGraph as possible, providing a familiar environment to veterans of the library and introducing newcomers to a popular and heavily-scrutinzed set of interfaces. 14 | -------------------------------------------------------------------------------- /website/contents/installation.md: -------------------------------------------------------------------------------- 1 | ### Installation 2 | 3 | First, clone a copy of the main git repo by running: 4 | 5 | git clone git://github.com/cedricpinson/osgjs.git 6 | cd osgjs 7 | 8 | # if you dont have grunt-cli installed 9 | # npm install -g grunt-cli 10 | npm install 11 | 12 | grunt build 13 | # The built version of osgjs will be put in the `builds/` subdirectory 14 | 15 | # use 'webpack -w' when you are developing to rebuild automatically when a file change 16 | 17 | grunt serve 18 | # open http://localhost:9000/examples or http://localhost:9000/tutorial 19 | -------------------------------------------------------------------------------- /website/contents/projects.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | title: They use OSG.JS 4 | examples: 5 | - 6 | title: Sketchfab.com 7 | image: assets/img/sketchfab.jpg 8 | link: http://sketchfab.com/ 9 | - 10 | title: Globe Tweeter 11 | image: assets/img/globetweeter.jpg 12 | link: http://cedricpinson.com/globetweeter/ 13 | - 14 | title: Nouvelle Vague 15 | image: assets/img/nouvellevague.jpg 16 | link: http://nouvellevague.ultranoir.com/ 17 | - 18 | title: VEditor 19 | image: assets/img/veditor.jpg 20 | link: http://cedricpinson.com/veditor/ 21 | - 22 | title: DemosJS 23 | image: assets/img/demojs-fff.jpg 24 | link: http://cedricpinson.com/demojs-fff/ 25 | - 26 | title: Terrain Editor 27 | image: assets/img/terrain.jpg 28 | link: http://www.chromeexperiments.com/detail/webgl-terrain-editor/ 29 | - 30 | title: PointCloudViz 31 | image: assets/img/pointcloudviz.jpg 32 | link: http://server.pointcloudviz.com 33 | - 34 | title: Typescript examples 35 | image: assets/img/peter.jpg 36 | link: http://marino.dk/mproject/ 37 | 38 | 39 | --- 40 | -------------------------------------------------------------------------------- /website/contents/support.md: -------------------------------------------------------------------------------- 1 | ## Need help? 2 | 3 | Here is how you can get help from the community and contribute: 4 | 5 | ### Forum / Mailing list 6 | Join the Google Group http://groups.google.com/group/osgjs 7 | 8 | ### IRC 9 | Join us on the #osgjs channel on Freenode 10 | 11 | ### E-mail 12 | Reach us by sending an e-mail to contact@osgjs.org 13 | 14 | ### Twitter 15 | Follow [@osgjs](http://twitter.com/osgjs) on Twitter. 16 | 17 | ### Blog 18 | Follow our [Blog](http://osgjs.tumblr.com) to get news and updates. 19 | 20 | ### Google+ 21 | Follow [Community news](https://plus.google.com/u/0/communities/105204964607979327212) on G+. 22 | -------------------------------------------------------------------------------- /website/push-website.sh: -------------------------------------------------------------------------------- 1 | path="$(dirname $(realpath $0) )" 2 | build_dir="$(realpath ${path}/../builds/web)" 3 | 4 | cd "${build_dir}" 5 | rm -rf osg-clone 6 | 7 | echo "OSGJS WEBSITE" >README 8 | rm -rf .git 9 | git init 10 | git add README 11 | git commit -m"ReadMe" 12 | git branch gh-pages 13 | git checkout gh-pages 14 | git add -Av . 15 | git commit -m"Update website" 16 | git remote add origin git@github.com:cedricpinson/osgjs-website.git 17 | git push -u origin gh-pages --force 18 | --------------------------------------------------------------------------------