Skip to content

Commit

Permalink
updated a bunch of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Oct 29, 2024
1 parent 7a420e8 commit fb99dbf
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 45 deletions.
34 changes: 21 additions & 13 deletions three.js/examples/measure-it.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- three.js library -->
<script src='vendor/three.js/build/three.js'></script>
<!-- include threex.artoolkit -->
<script src="../build/ar-threex.js"></script>
<script>THREEx.ArToolkitContext.baseURL = '../'</script>
<!-- include threex.artoolkit and three.js -->
<script type="importmap">
{
"imports": {
"threex": "../build/ar-threex.module.js",
"three": "./vendor/three.js/build/three.module.min.js"
}
}
</script>

<body style='margin : 0px; overflow: hidden; font-family: Monospace;'>
<div style='position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'>
Expand Down Expand Up @@ -83,7 +87,11 @@
}
}
</style>
<script>
<script type="module">
import * as THREE from 'three'
import { ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'

ArToolkitContext.baseURL = '../'
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -124,7 +132,7 @@
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////

var arToolkitSource = new THREEx.ArToolkitSource({
var arToolkitSource = new ArToolkitSource({
// to read from the webcam
sourceType: 'webcam',

Expand Down Expand Up @@ -159,8 +167,8 @@
function initARContext() {
console.log('initARContext()');
// create atToolkitContext
arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
arToolkitContext = new ArToolkitContext({
cameraParametersUrl: ArToolkitContext.baseURL + '../data/data/camera_para.dat',
detectionMode: 'mono',
})
// initialize it
Expand All @@ -174,16 +182,16 @@
window.arToolkitContext = arToolkitContext;
})
// build markerControls for markerRoot1
markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot1, {
markerControls = new ArMarkerControls(arToolkitContext, markerRoot1, {
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro',
patternUrl: ArToolkitContext.baseURL + '../data/data/patt.hiro',
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji',
})
// build markerControls for markerRoot2
markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot2, {
markerControls = new ArMarkerControls(arToolkitContext, markerRoot2, {
type: 'pattern',
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro',
patternUrl: THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji',
patternUrl: ArToolkitContext.baseURL + '../data/data/patt.kanji',
})
}

Expand Down
29 changes: 19 additions & 10 deletions three.js/examples/minimal_ES6.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="import" href="resources/index.css">
<!-- three.js library -->
<script src='vendor/three.js/build/three.min.js'></script>
<!-- ar.js -->
<script src="../build/ar-threex.js"></script>
<script>THREEx.ArToolkitContext.baseURL = '../'</script>
<!-- three.js and threex library -->
<script type="importmap">
{
"imports": {
"threex": "../build/ar-threex.module.js",
"three": "./vendor/three.js/build/three.module.min.js"
}
}
</script>

<body style='font-family: Monospace;'><div style='position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'>
<a href="https://github.com/AR-js-org/AR.js/" target="_blank">AR.js</a> - three.js camera transform
<br/>
Contact me any time at <a href='https://twitter.com/nicolocarp' target='_blank'>@nicolocarp</a>
</div><script>
</div>
<script type="module">
import * as THREE from 'three'
import { ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'

ArToolkitContext.baseURL = '../'
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////

const cameraParam = "../../data/data/camera_para.dat"
var arToolkitSource, arToolkitContext;
var arToolkitSource, arToolkitContext, arMarkerControls;

// init renderer
var renderer = new THREE.WebGLRenderer({
Expand Down Expand Up @@ -49,7 +58,7 @@
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////

arToolkitSource = new THREEx.ArToolkitSource({
arToolkitSource = new ArToolkitSource({
// to read from the webcam
sourceType : 'webcam',
sourceWidth: window.innerWidth > window.innerHeight ? 640 : 480,
Expand Down Expand Up @@ -77,7 +86,7 @@
console.log('initARContext()');

// CONTEXT
arToolkitContext = new THREEx.ArToolkitContext({
arToolkitContext = new ArToolkitContext({
cameraParametersUrl: cameraParam,
detectionMode: 'mono_and_matrix',
matrixCodeType: '3x3',
Expand All @@ -98,7 +107,7 @@
});

// MARKER
arMarkerControls = new THREEx.ArMarkerControls(arToolkitContext, camera, {
arMarkerControls = new ArMarkerControls(arToolkitContext, camera, {
type: 'barcode',
barcodeValue: 0,
smooth: true,
Expand Down
34 changes: 22 additions & 12 deletions three.js/examples/mobile-performance.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- three.js library -->
<script src='vendor/three.js/build/three.min.js'></script>
<!-- stats.min.js library -->

<script src="vendor/three.js/examples/js/libs/stats.min.js"></script>
<!-- ar.js -->
<script src="../build/ar-threex.js"></script>
<script>THREEx.ArToolkitContext.baseURL = '../'</script>
<!-- three.js and threex library -->
<script type="importmap">
{
"imports": {
"threex": "../build/ar-threex.module.js",
"three": "./vendor/three.js/build/three.module.min.js"
}
}
</script>

<body style='margin : 0px; overflow: hidden; font-family: Monospace;'>
<div style='position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'>
<a href="https://github.com/AR-js-org/AR.js/" target="_blank">AR.js</a> - three.js mobile performance
<br />
Contact me any time at <a href='https://twitter.com/nicolocarp' target='_blank'>@nicolocarp</a>
</div>
<script>
<script type="module">
import * as THREE from 'three'
import { ArSmoothedControls, ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'

ArToolkitContext.baseURL = '../'
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -53,7 +63,7 @@
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////

var arToolkitSource = new THREEx.ArToolkitSource({
var arToolkitSource = new ArToolkitSource({
// to read from the webcam
sourceType: 'webcam',

Expand Down Expand Up @@ -91,8 +101,8 @@
function initARContext() {
console.log('initARContext()');

arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
arToolkitContext = new ArToolkitContext({
cameraParametersUrl: ArToolkitContext.baseURL + '../data/data/camera_para.dat',
detectionMode: 'mono',
maxDetectionRate: 30,
canvasWidth: 80 * 3,
Expand All @@ -108,9 +118,9 @@
console.log('arToolkitContext', arToolkitContext);
window.arToolkitContext = arToolkitContext;
})
artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, {
artoolkitMarker = new ArMarkerControls(arToolkitContext, markerRoot, {
type: 'pattern',
patternUrl: THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
patternUrl: ArToolkitContext.baseURL + '../data/data/patt.hiro'
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji'
})
}
Expand Down Expand Up @@ -156,7 +166,7 @@
// build a smoothedControls
var smoothedRoot = new THREE.Group()
scene.add(smoothedRoot)
var smoothedControls = new THREEx.ArSmoothedControls(smoothedRoot, {
var smoothedControls = new ArSmoothedControls(smoothedRoot, {
lerpPosition: 0.4,
lerpQuaternion: 0.3,
lerpScale: 1,
Expand Down
29 changes: 19 additions & 10 deletions three.js/examples/profile.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- three.js library -->
<script src='vendor/three.js/build/three.js'></script>
<!-- stats.js library -->
<script src="vendor/three.js/examples/js/libs/stats.min.js"></script>
<!-- include threex.artoolkit -->
<script src="../build/ar-threex.js"></script>
<script>THREEx.ArToolkitContext.baseURL = '../'</script>
<!-- include three.js and threex.artoolkit -->
<script type="importmap">
{
"imports": {
"threex": "../build/ar-threex.module.js",
"three": "./vendor/three.js/build/three.module.min.js"
}
}
</script>

<body style='margin : 0px; overflow: hidden; font-family: Monospace;'>
<div style='position: absolute; top: 10px; width:100%; text-align: center;z-index:1' ;>
Expand All @@ -25,7 +30,11 @@
</select>
</label>
</div>
<script>
<script type="module">
import * as THREE from 'three'
import { ArToolkitProfile, ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'

ArToolkitContext.baseURL = '../'
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -88,7 +97,7 @@
////////////////////////////////////////////////////////////////////////////////


var artoolkitProfile = new THREEx.ArToolkitProfile()
var artoolkitProfile = new ArToolkitProfile()
artoolkitProfile.sourceWebcam()
// artoolkitProfile.sourceVideo(THREEx.ArToolkitContext.baseURL + '../data/videos/headtracking.mp4').kanjiMarker();
// artoolkitProfile.sourceImage(THREEx.ArToolkitContext.baseURL + '../data/images/img.jpg').hiroMarker()
Expand All @@ -105,7 +114,7 @@
// handle arToolkitSource
//////////////////////////////////////////////////////////////////////////////

var arToolkitSource = new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters)
var arToolkitSource = new ArToolkitSource(artoolkitProfile.sourceParameters)

arToolkitSource.init(function onReady() {
initARContext()
Expand All @@ -130,7 +139,7 @@
function initARContext() {
console.log('initARContext()');
// create atToolkitContext
arToolkitContext = new THREEx.ArToolkitContext(artoolkitProfile.contextParameters)
arToolkitContext = new ArToolkitContext(artoolkitProfile.contextParameters)
// initialize it
arToolkitContext.init(function onCompleted() {
// copy projection matrix to camera
Expand All @@ -141,7 +150,7 @@
console.log('arToolkitContext', arToolkitContext);
window.arToolkitContext = arToolkitContext;
})
artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, artoolkitProfile.defaultMarkerParameters)
artoolkitMarker = new ArMarkerControls(arToolkitContext, markerRoot, artoolkitProfile.defaultMarkerParameters)
}

function getSourceOrientation() {
Expand Down

0 comments on commit fb99dbf

Please sign in to comment.