This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.18) | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
project(BabylonNative) | |
include(FetchContent) | |
FetchContent_Declare(babylonnative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addBodiesPG.js | |
https://playground.babylonjs.com/?snapshot=refs/pull/13757/merge#RQIZD3#1 | |
aggregateReuseShapePG | |
https://playground.babylonjs.com/?snapshot=refs/pull/13757/merge#4Y813L#1 | |
blockTowerPG | |
https://playground.babylonjs.com/?snapshot=refs/pull/13757/merge#FWTRDD#3 | |
centerOfMassPG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useful commands | |
# list already installed Android packages : $ANDROID_HOME/tools/bin/sdkmanager --list | |
# stop activity : adb shell am force-stop com.android.babylonnative.playground | |
# test activity is running : adb shell pidof com.android.babylonnative.playground | |
#$ANDROID_HOME/platform-tools/adb devices | |
# adb shell pm grant com.android.babylonnative.playground android.permission.CAMERA | |
# rotate screen | |
# adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0 | |
# adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1 | |
- bash: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wireframe = false; | |
var turntable = false; | |
var logfps = true; | |
var ibl = false; | |
var rtt = false; | |
var vr = false; | |
var ar = false; | |
var xrHitTest = false; | |
var xrFeaturePoints = false; | |
var text = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trail.data.shift(); trail.data.shift(); trail.data.shift(); trail.data.shift(); | |
trail.data.push(newPos.x, newPos.y, newPos.z, 0.); | |
if (!trail.texture) { | |
trail.texture = BABYLON.RawTexture.CreateRGBATexture(new Float32Array(trail.data), 1, trail.data.length / 4, scene, false, false, BABYLON.Texture.LINEAR_LINEAR, BABYLON.Engine.TEXTURETYPE_FLOAT); | |
trail.trackSampler0Block.texture = trail.texture; | |
trail.trackSampler1Block.texture = trail.texture; | |
} else { | |
trail.texture.update(new Float32Array(trail.data)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var trailMesh = BABYLON.MeshBuilder.CreateGround("trail", {width: 0.1, height: 0.010, subdivisionsY:256}, scene); | |
trailMesh.setBoundingInfo(new BABYLON.BoundingInfo(new BABYLON.Vector3(-1000,-1000,-1000), new BABYLON.Vector3(1000,1000,1000))); | |
trailMaterial.backFaceCulling = true; | |
trailMesh.material = trailMaterial; | |
var trackSampler0Block = trailMaterial.getBlockByPredicate((b) => b.name === "tailSampler0"); | |
var trackSampler1Block = trailMaterial.getBlockByPredicate((b) => b.name === "tailSampler1"); | |
var data = new Array(trailLength * 4); | |
for (let i = 0; i < trailLength; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The *recommended* precompiled SDK download is 1.39.6 (967836071d96d9b7894e492382f5fcb96423fc07). | |
To install/activate it, use one of: | |
latest [default (llvm) backend] | |
latest-fastcomp [legacy (fastcomp) backend] | |
Those are equivalent to installing/activating the following: | |
1.39.6 | |
1.39.6-fastcomp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arcana::make_task(arcana::threadpool_scheduler, m_cancelSource, | |
[this, dataSpan, generateMips, invertY, onErrorRef = Napi::Persistent(onError)]() { | |
try | |
{ | |
bimg::ImageContainer* image = bimg::imageParse(&m_allocator, dataSpan.data(), static_cast<uint32_t>(dataSpan.size())); | |
// todo: bimg::imageParse will return nullptr when trying to load a texture with an url that is not a valid texture | |
// Like a 404 html page. | |
if (invertY) | |
{ | |
FlipY(image); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float distanceFromSurface = 0.0; | |
float step = 0.03; | |
vec3 previousPosition = vPosition; | |
float previousDistance = 0.; | |
for (int i = 0; i < 100; i++) { | |
vec3 currentPosition = vPosition + distanceFromSurface * rayDir; | |
float distance = sphereDistance(currentPosition, sphereCenter, 1.0); | |
if (distance < 0.) { | |
vec3 hitPosition = mix(previousPosition, currentPosition, previousDistance / (previousDistance - distance)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (sphereDistance(currentPosition, sphereCenter, 1.0) < 0.) { | |
vec3 normal = (currentPosition - sphereCenter); | |
float dotLight = dot(normal, ligthDirection) * 0.5 + 0.5; | |
float noiseTexture = simplex3d(currentPosition * 4.0) * 0.5 + 0.5; | |
gl_FragColor = vec4(vec3(1.0, 0.5, 0.2) * dotLight * noiseTexture, 1.0); | |
return; | |
} |
NewerOlder