clone3 commited on
Commit
6b986d1
·
verified ·
1 Parent(s): 16a1384

Upload 14 files

Browse files
.gitattributes CHANGED
@@ -34,3 +34,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  Build/Build.data filter=lfs diff=lfs merge=lfs -text
 
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  Build/Build.data filter=lfs diff=lfs merge=lfs -text
37
+ Build/Build.data.unityweb filter=lfs diff=lfs merge=lfs -text
38
+ Build/Build.wasm.code.unityweb filter=lfs diff=lfs merge=lfs -text
Build/Build.data.unityweb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb45e233ab3bd761e4d84679cce5c31e31905e54283697500d9aa165b6e84382
3
+ size 5631879
Build/Build.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "companyName": "DefaultCompany",
3
+ "productName": "WebAr",
4
+ "productVersion": "0.1",
5
+ "dataUrl": "Build.data.unityweb",
6
+ "wasmCodeUrl": "Build.wasm.code.unityweb",
7
+ "wasmFrameworkUrl": "Build.wasm.framework.unityweb",
8
+ "graphicsAPI": ["WebGL 2.0","WebGL 1.0"],
9
+ "webglContextAttributes": {"preserveDrawingBuffer": false},
10
+ "splashScreenStyle": "Dark",
11
+
12
+ "cacheControl": {"default": "must-revalidate"},
13
+ "developmentBuild": false,
14
+ "multithreading": false,
15
+ "unityVersion": "2019.4.26f1"
16
+ }
Build/Build.wasm.code.unityweb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97e4d6811831e229039706d7398dc413b44f278a3b9a44132e40402362bc17b5
3
+ size 13683444
Build/Build.wasm.framework.unityweb ADDED
The diff for this file is too large to render. See raw diff
 
Build/UnityLoader.js ADDED
The diff for this file is too large to render. See raw diff
 
ThreeVersion/appThree.js ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //import ------------------------------------------------------
2
+
3
+ var unityContainer = document.getElementById("unityContainer")
4
+ let unityInstance = UnityLoader.instantiate("unityContainer", "Build/WebGLtest.json", {onProgress: unityProgress});
5
+
6
+ var unityCanvas = document.getElementsByTagName('canvas')[0];
7
+
8
+ function unityProgress(unityInstance, progress) {
9
+ if (!unityInstance.Module)
10
+ return;
11
+ if (!unityInstance.logo) {
12
+ unityInstance.logo = document.createElement("div");
13
+ unityInstance.logo.className = "logo " + unityInstance.Module.splashScreenStyle;
14
+ unityInstance.container.appendChild(unityInstance.logo);
15
+ }
16
+ if (!unityInstance.progress) {
17
+ unityInstance.progress = document.createElement("div");
18
+ unityInstance.progress.className = "progress " + unityInstance.Module.splashScreenStyle;
19
+ unityInstance.progress.empty = document.createElement("div");
20
+ unityInstance.progress.empty.className = "empty";
21
+ unityInstance.progress.appendChild(unityInstance.progress.empty);
22
+ unityInstance.progress.full = document.createElement("div");
23
+ unityInstance.progress.full.className = "full";
24
+ unityInstance.progress.appendChild(unityInstance.progress.full);
25
+ unityInstance.container.appendChild(unityInstance.progress);
26
+ }
27
+ unityInstance.progress.full.style.width = (100 * progress) + "%";
28
+ unityInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
29
+
30
+ onResize()
31
+
32
+ if (progress < 1){
33
+ arToolkitSource.domElement.style.opacity = 0
34
+ }
35
+
36
+ if (progress == 1){
37
+ arToolkitSource.domElement.style.opacity = 1
38
+ unityInstance.logo.style.display = unityInstance.progress.style.display = "none";
39
+ }
40
+ }
41
+
42
+ //three base ------------------------------------------------------
43
+
44
+ var onRenderFcts= [];
45
+
46
+ var scene = new THREE.Scene();
47
+
48
+ var camera = new THREE.PerspectiveCamera( 60, window.innerWidth/window.innerHeight, 0.1, 1000 );
49
+
50
+ var renderer = new THREE.WebGLRenderer({
51
+ antialias: true,
52
+ alpha: true
53
+ });
54
+
55
+ renderer.setClearColor(new THREE.Color('lightgrey'), 0)
56
+
57
+ renderer.setSize( window.innerWidth, window.innerHeight );
58
+ // renderer.domElement.style.position = 'absolute'
59
+ // renderer.domElement.style.top = '0px'
60
+ // renderer.domElement.style.left = '0px'
61
+
62
+ document.body.appendChild( renderer.domElement );
63
+
64
+ //artoolkit ------------------------------------------------------
65
+
66
+ var arToolkitSource = new THREEx.ArToolkitSource({
67
+ sourceType : 'webcam',
68
+ })
69
+
70
+ arToolkitSource.init(function onReady(){
71
+ onResize()
72
+ })
73
+
74
+ window.addEventListener('resize', function(){
75
+ onResize()
76
+ })
77
+
78
+ function onResize(){
79
+ arToolkitSource.onResizeElement()
80
+ arToolkitSource.copyElementSizeTo(renderer.domElement)
81
+ arToolkitSource.copyElementSizeTo(unityCanvas)
82
+
83
+ if( arToolkitContext.arController !== null ){
84
+ arToolkitSource.copyElementSizeTo(arToolkitContext.arController.canvas)
85
+
86
+ }
87
+ }
88
+
89
+ var arToolkitContext = new THREEx.ArToolkitContext({
90
+ cameraParametersUrl: 'data/camera/camera_para.dat',
91
+ detectionMode: 'mono',
92
+ })
93
+
94
+ arToolkitContext.init(function onCompleted(){
95
+ camera.projectionMatrix.copy( arToolkitContext.getProjectionMatrix() );
96
+ })
97
+
98
+
99
+ onRenderFcts.push(function(){
100
+ if( arToolkitSource.ready === false ) return
101
+
102
+ arToolkitContext.update( arToolkitSource.domElement )
103
+ })
104
+
105
+ //3d els ------------------------------------------------------
106
+
107
+ var geometry = new THREE.BoxGeometry( 1, 1, 1 );
108
+ var material = new THREE.MeshNormalMaterial({
109
+ transparent : true,
110
+ opacity: 0.5,
111
+ side: THREE.DoubleSide
112
+ });
113
+
114
+ var cube = new THREE.Mesh( geometry, material );
115
+
116
+ // cube.position.x = 6;
117
+ // cube.position.y = 4;
118
+ // cube.position.z = -13;
119
+
120
+ scene.add( cube );
121
+
122
+ var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, cube, {
123
+ type : 'pattern',
124
+ patternUrl : '/data/markers/patt.hiro',
125
+ })
126
+
127
+
128
+ var render = function () {
129
+ requestAnimationFrame( render );
130
+
131
+ // cube.rotation.x += 0.01;
132
+ // cube.rotation.y += 0.01;
133
+
134
+ renderer.render(scene, camera);
135
+ };
136
+
137
+ render();
138
+
139
+ var lastTimeMsec= null
140
+ requestAnimationFrame(function animate(nowMsec){
141
+ // keep looping
142
+ requestAnimationFrame( animate );
143
+ // measure time
144
+ lastTimeMsec = lastTimeMsec || nowMsec-1000/60
145
+ var deltaMsec = Math.min(200, nowMsec - lastTimeMsec)
146
+ lastTimeMsec = nowMsec
147
+ // call each update function
148
+ onRenderFcts.forEach(function(onRenderFct){
149
+ onRenderFct(deltaMsec/1000, nowMsec/1000)
150
+ })
151
+ })
152
+
153
+ //Unity ------------------------------------------------------
154
+
155
+ onResize()
156
+
157
+ window.STATUSCUBE = false;
158
+ window.STATUSCAM = false;
159
+
160
+ function camControlReady(){
161
+ window.STATUSCAM = true;
162
+ }
163
+
164
+ function cubeControlReady(){
165
+ window.STATUSCUBE = true;
166
+ }
167
+
168
+
169
+ function createUnityMatrix(el){
170
+ var m = el.matrix.clone();
171
+ var zFlipped = new THREE.Matrix4().makeScale(1, 1, -1).multiply(m);
172
+ var rotated = zFlipped.multiply(new THREE.Matrix4().makeRotationX(-Math.PI/2));
173
+ return rotated;
174
+ }
175
+
176
+ onRenderFcts.push(function(){
177
+
178
+ var camtr = new THREE.Vector3(),
179
+ camro = new THREE.Quaternion(),
180
+ camsc = new THREE.Vector3();
181
+
182
+ camera.matrix.clone().decompose(camtr, camro, camsc);
183
+
184
+ let projection = camera.projectionMatrix.clone();
185
+ let tosend = `${[...projection.elements]}`
186
+
187
+ let posCam = `${[...camtr.toArray()]}`
188
+ let rotCam = `${[...camro.toArray()]}`
189
+
190
+ if(window.STATUSCAM){
191
+ unityInstance.SendMessage("Main Camera", "setProjection", tosend);
192
+ unityInstance.SendMessage("Main Camera", "setAspect", camera.aspect);
193
+
194
+ unityInstance.SendMessage("Main Camera", "setPosition", posCam);
195
+ unityInstance.SendMessage("Main Camera", "setRotation", rotCam);
196
+ }
197
+
198
+
199
+ var tr = new THREE.Vector3(),
200
+ ro = new THREE.Quaternion(),
201
+ sc = new THREE.Vector3();
202
+ // var m = createUnityMatrix(cube);
203
+ // console.log(m);
204
+ // console.log(JSON.stringify(m.elements));
205
+ // let tosend = `${[...m.elements]}`
206
+ createUnityMatrix(cube).decompose(tr, ro, sc);
207
+
208
+ // console.log(camera.fov, camera.getFocalLength(), camera.getEffectiveFOV(), camera.zoom)
209
+
210
+ var posCube = tr.x.toString().concat(",", tr.y.toString(), ",", tr.z.toString());
211
+ var scaleCube = sc.x.toString().concat(",", sc.y.toString(), ",", sc.z.toString());
212
+ var rotCube = ro.x.toString().concat(",", ro.y.toString(), ",", ro.z.toString(), ",", ro.w.toString());
213
+
214
+
215
+ if(window.STATUSCUBE){
216
+ unityInstance.SendMessage("Cube", "setRotation", rotCube);
217
+ unityInstance.SendMessage("Cube", "setScale", scaleCube);
218
+ unityInstance.SendMessage("Cube", "setPosition", posCube);
219
+ }
220
+ })
ThreeVersion/indexThree.html ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en-us">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
+ <title>Unity WebGL Player | WebGL Test AR</title>
7
+ <script src="https://threejs.org/build/three.js"></script>
8
+ <script src="js/lib/ar.js"></script>
9
+ <script src="Build/UnityLoader.js"></script>
10
+
11
+ <style>
12
+ body{
13
+ margin: 0;
14
+ }
15
+
16
+ /* html, body{
17
+ width: 100vw;
18
+ min-height: -webkit-fill-available;
19
+ } */
20
+
21
+ #unityContainer{
22
+ margin: 0;
23
+ width: 100%;
24
+ height: 100%;
25
+ }
26
+
27
+ canvas{
28
+ margin: 0;
29
+ width: 100%;
30
+ height: 100%;
31
+ }
32
+
33
+ </style>
34
+ </head>
35
+
36
+ <body>
37
+ <div id="unityContainer"></div>
38
+ <script src="ThreeVersion/appThree.js"></script>
39
+ </body>
40
+ </html>
data/camera/camera_para.dat ADDED
Binary file (176 Bytes). View file
 
data/markers/pi.patt ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
2
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
3
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
4
+ 255 255 255 255 255 36 255 255 255 1 0 255 255 255 255 255
5
+ 255 255 255 255 255 36 255 255 255 36 255 255 255 255 255 255
6
+ 255 255 255 255 255 255 36 36 36 255 36 255 255 255 255 255
7
+ 255 255 255 255 255 255 36 36 36 36 36 255 255 255 255 255
8
+ 255 255 255 255 255 255 0 36 0 36 36 255 255 255 255 255
9
+ 255 255 255 255 255 255 16 36 36 36 255 255 255 255 255 255
10
+ 255 255 255 255 255 255 36 36 36 255 255 255 255 255 255 255
11
+ 255 255 255 255 255 255 36 29 36 16 255 255 255 255 255 255
12
+ 255 255 255 255 255 255 36 36 36 217 255 255 255 255 255 255
13
+ 255 255 255 255 255 36 36 14 36 36 255 255 255 255 255 255
14
+ 255 255 255 255 255 255 2 29 36 29 255 255 255 255 255 255
15
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
16
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
17
+ 124 124 124 124 124 124 126 129 129 126 124 124 124 124 124 124
18
+ 124 124 124 124 129 133 136 137 137 136 133 129 124 124 124 124
19
+ 124 124 126 132 137 141 143 146 145 144 141 137 132 126 124 124
20
+ 124 124 132 138 143 218 151 153 153 8 0 143 138 132 124 124
21
+ 124 130 137 143 150 218 159 161 161 218 155 150 143 137 130 124
22
+ 124 132 141 148 155 161 218 218 218 166 218 155 148 141 133 124
23
+ 127 135 143 151 159 166 218 218 218 218 218 159 151 143 136 126
24
+ 129 136 145 153 161 169 3 218 38 218 218 161 153 145 136 128
25
+ 128 136 145 153 161 169 51 218 218 218 169 161 153 145 136 129
26
+ 126 135 143 150 159 166 218 218 218 172 166 159 150 143 135 126
27
+ 124 133 141 148 154 161 218 151 218 67 160 155 147 141 133 124
28
+ 124 129 136 143 149 154 218 218 218 137 154 149 143 136 129 124
29
+ 124 124 132 137 143 218 218 82 218 218 147 143 137 131 124 124
30
+ 124 124 125 131 136 140 12 151 218 151 140 136 131 125 124 124
31
+ 124 124 124 124 129 132 134 136 136 134 132 129 124 124 124 124
32
+ 124 124 124 124 124 124 126 128 126 126 124 124 124 124 124 124
33
+ 147 147 147 147 147 147 149 150 150 149 147 147 147 147 147 147
34
+ 147 147 147 148 151 154 156 157 157 156 154 151 147 147 147 147
35
+ 147 147 149 153 157 160 162 164 163 163 160 157 153 149 147 147
36
+ 147 147 153 158 162 255 169 170 170 10 0 162 158 153 147 147
37
+ 147 151 157 162 168 255 175 177 177 255 172 168 162 157 151 147
38
+ 147 153 160 166 172 177 255 255 255 181 255 172 166 160 154 147
39
+ 149 155 162 169 175 181 255 255 255 255 255 175 169 162 156 149
40
+ 150 156 163 170 177 183 3 255 77 255 255 177 170 163 156 150
41
+ 150 156 163 170 177 184 255 255 255 255 183 177 170 163 156 150
42
+ 149 155 162 168 175 181 255 255 255 186 181 175 168 162 155 149
43
+ 147 154 160 166 171 177 255 230 255 208 176 172 165 160 154 147
44
+ 147 150 156 162 167 171 255 255 255 150 171 167 162 156 150 147
45
+ 147 147 153 157 162 255 255 96 255 255 165 162 157 152 147 147
46
+ 147 147 147 152 156 159 18 230 255 230 160 156 152 148 147 147
47
+ 147 147 147 147 151 153 155 156 156 155 153 150 147 147 147 147
48
+ 147 147 147 147 147 147 149 149 149 149 147 147 147 147 147 147
49
+
50
+ 241 240 242 241 242 242 241 242 242 242 242 242 242 241 242 204
51
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
52
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
53
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
54
+ 255 255 255 255 209 170 193 240 255 255 255 255 255 255 255 216
55
+ 255 255 221 119 197 45 36 109 244 186 255 255 246 255 255 216
56
+ 255 255 255 137 45 107 34 35 43 76 94 140 60 90 227 216
57
+ 255 255 255 255 177 35 40 36 29 32 35 35 35 32 179 216
58
+ 255 255 255 255 176 36 36 35 33 36 34 33 31 35 224 216
59
+ 255 255 255 241 143 54 68 55 27 85 66 36 34 30 194 216
60
+ 255 255 217 53 109 235 255 255 255 255 255 213 105 160 251 216
61
+ 255 255 196 222 255 255 255 255 255 255 255 255 255 255 255 216
62
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
63
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
64
+ 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 216
65
+ 242 242 242 242 242 242 241 242 242 242 242 242 242 242 241 204
66
+ 118 129 118 118 118 119 120 121 122 120 118 118 118 118 118 108
67
+ 124 147 123 124 127 131 133 135 135 133 130 126 124 123 123 113
68
+ 123 123 124 129 135 139 141 143 143 141 138 134 129 124 123 112
69
+ 123 124 129 135 141 146 149 151 151 149 145 140 135 128 124 113
70
+ 123 127 134 141 146 166 163 157 159 156 152 146 140 134 126 113
71
+ 124 131 119 91 133 205 218 183 164 163 158 152 143 138 129 113
72
+ 126 133 142 168 205 167 207 203 151 172 149 171 178 151 128 115
73
+ 126 135 143 151 162 215 203 157 170 193 212 214 212 193 135 116
74
+ 126 135 143 151 163 218 218 213 202 218 205 202 191 168 135 116
75
+ 126 133 142 147 170 202 188 139 112 166 198 217 208 182 128 114
76
+ 124 131 133 165 178 158 164 167 166 163 158 152 159 135 128 113
77
+ 123 127 102 122 147 152 157 159 159 156 152 147 140 134 126 113
78
+ 123 124 129 135 141 145 149 151 151 149 145 140 135 128 124 113
79
+ 123 123 124 129 134 139 141 143 143 141 138 134 128 124 123 113
80
+ 123 123 123 124 127 131 133 135 134 133 130 126 124 123 123 112
81
+ 118 118 118 118 118 119 120 122 122 120 118 118 118 118 118 108
82
+ 140 148 140 140 140 140 141 142 142 141 140 140 140 140 140 127
83
+ 147 166 147 147 149 151 153 155 155 153 151 148 147 147 147 133
84
+ 147 147 147 150 154 158 160 162 161 160 157 154 150 147 147 133
85
+ 147 147 150 156 160 164 166 168 168 166 163 160 155 150 147 133
86
+ 147 149 155 160 166 189 183 174 174 172 169 164 159 154 148 133
87
+ 147 151 137 103 150 240 255 210 179 182 174 169 161 157 151 133
88
+ 148 154 160 194 240 192 244 238 222 208 196 197 209 199 152 134
89
+ 148 155 162 169 183 253 238 185 240 241 249 252 249 237 162 135
90
+ 148 155 162 169 184 255 255 250 238 255 249 238 230 215 156 135
91
+ 148 154 160 165 195 236 217 163 224 207 231 255 244 230 156 134
92
+ 147 151 152 193 206 175 179 181 181 178 174 171 188 174 149 133
93
+ 147 149 118 139 165 169 173 175 175 172 169 165 159 154 148 133
94
+ 147 147 151 156 160 163 166 168 168 166 163 160 155 150 147 133
95
+ 147 147 147 150 154 158 160 162 162 160 157 154 150 147 147 133
96
+ 147 147 147 147 148 151 153 155 155 153 151 148 147 147 147 133
97
+ 140 141 140 141 140 140 141 142 142 141 140 140 140 141 140 127
98
+
99
+ 204 216 216 216 216 216 216 216 216 216 216 216 216 216 216 204
100
+ 242 255 255 255 255 255 227 179 224 194 251 255 255 255 255 241
101
+ 241 255 255 255 255 255 90 32 35 30 160 255 255 255 255 242
102
+ 242 255 255 255 255 246 60 35 31 34 105 255 255 255 255 242
103
+ 242 255 255 255 255 255 140 35 33 36 213 255 255 255 255 242
104
+ 242 255 255 255 255 255 94 35 34 66 255 255 255 255 255 242
105
+ 242 255 255 255 255 186 76 32 36 85 255 255 255 255 255 242
106
+ 242 255 255 255 255 244 43 29 33 27 255 255 255 255 255 242
107
+ 242 255 255 255 240 109 35 36 35 55 255 255 255 255 255 242
108
+ 241 255 255 255 193 36 34 40 36 68 255 255 255 255 255 241
109
+ 242 255 255 255 170 45 107 35 36 54 235 255 255 255 255 242
110
+ 242 255 255 255 209 197 45 177 176 143 109 255 255 255 255 242
111
+ 241 255 255 255 255 119 137 255 255 241 53 222 255 255 255 242
112
+ 242 255 255 255 255 221 255 255 255 255 217 196 255 255 255 242
113
+ 240 255 255 255 255 255 255 255 255 255 255 255 255 255 255 242
114
+ 241 255 255 255 255 255 255 255 255 255 255 255 255 255 255 242
115
+ 108 113 112 113 113 113 115 116 116 114 113 113 113 113 112 108
116
+ 118 123 123 124 126 129 128 135 135 128 128 126 124 123 123 118
117
+ 118 123 124 128 134 138 151 193 168 182 135 134 128 124 123 118
118
+ 118 124 129 135 140 143 178 212 191 208 159 140 135 128 124 118
119
+ 118 126 134 140 146 152 171 214 202 217 152 147 140 134 126 118
120
+ 118 130 138 145 152 158 149 212 205 198 158 152 145 138 130 118
121
+ 120 133 141 149 156 163 172 193 218 166 163 156 149 141 133 120
122
+ 122 135 143 151 159 164 151 170 202 112 166 159 151 143 134 122
123
+ 121 135 143 151 157 183 203 157 213 139 167 159 151 143 135 122
124
+ 120 133 141 149 163 218 207 203 218 188 164 157 149 141 133 120
125
+ 119 131 139 146 166 205 167 215 218 202 158 152 145 139 131 119
126
+ 118 127 135 141 146 133 205 162 163 170 178 147 141 134 127 118
127
+ 118 124 129 135 141 91 168 151 151 147 165 122 135 129 124 118
128
+ 118 123 124 129 134 119 142 143 143 142 133 102 129 124 123 118
129
+ 129 147 123 124 127 131 133 135 135 133 131 127 124 123 123 118
130
+ 118 124 123 123 123 124 126 126 126 126 124 123 123 123 123 118
131
+ 127 133 133 133 133 133 134 135 135 134 133 133 133 133 133 127
132
+ 140 147 147 147 148 151 152 162 156 156 149 148 147 147 147 140
133
+ 140 147 147 150 154 157 199 237 215 230 174 154 150 147 147 141
134
+ 140 147 150 155 159 161 209 249 230 244 188 159 155 150 147 140
135
+ 140 148 154 160 164 169 197 252 238 255 171 165 160 154 148 140
136
+ 140 151 157 163 169 174 196 249 249 231 174 169 163 157 151 140
137
+ 141 153 160 166 172 182 208 241 255 207 178 172 166 160 153 141
138
+ 142 155 161 168 174 179 222 240 238 224 181 175 168 162 155 142
139
+ 142 155 162 168 174 210 238 185 250 163 181 175 168 162 155 142
140
+ 141 153 160 166 183 255 244 238 255 217 179 173 166 160 153 141
141
+ 140 151 158 164 189 240 192 253 255 236 175 169 163 158 151 140
142
+ 140 149 154 160 166 150 240 183 184 195 206 165 160 154 148 140
143
+ 140 147 150 156 160 103 194 169 169 165 193 139 156 150 147 141
144
+ 140 147 147 150 155 137 160 162 162 160 152 118 151 147 147 140
145
+ 148 166 147 147 149 151 154 155 155 154 151 149 147 147 147 141
146
+ 140 147 147 147 147 147 148 148 148 148 147 147 147 147 147 140
147
+
148
+ 204 241 242 242 242 242 242 242 242 241 242 242 242 242 242 242
149
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
150
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
151
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
152
+ 216 255 255 255 255 255 255 255 255 255 255 255 222 196 255 255
153
+ 216 251 160 105 213 255 255 255 255 255 235 109 53 217 255 255
154
+ 216 194 30 34 36 66 85 27 55 68 54 143 241 255 255 255
155
+ 216 224 35 31 33 34 36 33 35 36 36 176 255 255 255 255
156
+ 216 179 32 35 35 35 32 29 36 40 35 177 255 255 255 255
157
+ 216 227 90 60 140 94 76 43 35 34 107 45 137 255 255 255
158
+ 216 255 255 246 255 255 186 244 109 36 45 197 119 221 255 255
159
+ 216 255 255 255 255 255 255 255 240 193 170 209 255 255 255 255
160
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
161
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
162
+ 216 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
163
+ 204 242 241 242 242 242 242 242 242 241 242 242 241 242 240 241
164
+ 108 118 118 118 118 118 120 122 122 120 119 118 118 118 118 118
165
+ 112 123 123 124 126 130 133 134 135 133 131 127 124 123 123 123
166
+ 113 123 124 128 134 138 141 143 143 141 139 134 129 124 123 123
167
+ 113 124 128 135 140 145 149 151 151 149 145 141 135 129 124 123
168
+ 113 126 134 140 147 152 156 159 159 157 152 147 122 102 127 123
169
+ 113 128 135 159 152 158 163 166 167 164 158 178 165 133 131 124
170
+ 114 128 182 208 217 198 166 112 139 188 202 170 147 142 133 126
171
+ 116 135 168 191 202 205 218 202 213 218 218 163 151 143 135 126
172
+ 116 135 193 212 214 212 193 170 157 203 215 162 151 143 135 126
173
+ 115 128 151 178 171 149 172 151 203 207 167 205 168 142 133 126
174
+ 113 129 138 143 152 158 163 164 183 218 205 133 91 119 131 124
175
+ 113 126 134 140 146 152 156 159 157 163 166 146 141 134 127 123
176
+ 113 124 128 135 140 145 149 151 151 149 146 141 135 129 124 123
177
+ 112 123 124 129 134 138 141 143 143 141 139 135 129 124 123 123
178
+ 113 123 123 124 126 130 133 135 135 133 131 127 124 123 147 124
179
+ 108 118 118 118 118 118 120 122 121 120 119 118 118 118 129 118
180
+ 127 140 141 140 140 140 141 142 142 141 140 140 141 140 141 140
181
+ 133 147 147 147 148 151 153 155 155 153 151 148 147 147 147 147
182
+ 133 147 147 150 154 157 160 162 162 160 158 154 150 147 147 147
183
+ 133 147 150 155 160 163 166 168 168 166 163 160 156 151 147 147
184
+ 133 148 154 159 165 169 172 175 175 173 169 165 139 118 149 147
185
+ 133 149 174 188 171 174 178 181 181 179 175 206 193 152 151 147
186
+ 134 156 230 244 255 231 207 224 163 217 236 195 165 160 154 148
187
+ 135 156 215 230 238 249 255 238 250 255 255 184 169 162 155 148
188
+ 135 162 237 249 252 249 241 240 185 238 253 183 169 162 155 148
189
+ 134 152 199 209 197 196 208 222 238 244 192 240 194 160 154 148
190
+ 133 151 157 161 169 174 182 179 210 255 240 150 103 137 151 147
191
+ 133 148 154 159 164 169 172 174 174 183 189 166 160 155 149 147
192
+ 133 147 150 155 160 163 166 168 168 166 164 160 156 150 147 147
193
+ 133 147 147 150 154 157 160 161 162 160 158 154 150 147 147 147
194
+ 133 147 147 147 148 151 153 155 155 153 151 149 147 147 166 147
195
+ 127 140 140 140 140 140 141 142 142 141 140 140 140 140 148 140
data/markersImages/pi.jpg ADDED
index.html ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en-us">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
+ <title>Unity WebGL Player | WebGL Test AR</title>
7
+ <script src="js/lib/aframe.min.js"></script>
8
+ <script src="js/lib/aframe-ar.js"></script>
9
+ <script src="Build/UnityLoader.js"></script>
10
+ <script src="js/app.js"></script>
11
+
12
+ </head>
13
+
14
+ <body style="margin: 0px; overflow: hidden;">
15
+ <a-scene embedded arjs vr-mode-ui="enabled: false" copycanvas>
16
+ <div id="unityContainer" style="z-index: 2" ></div>
17
+ <!-- <a-marker preset="hiro"> <a-box></a-box> </a-marker> -->
18
+ <!-- <a-marker type="pattern" url="data/markers/pattern-arjs.patt"><a-box></a-box></a-marker> -->
19
+ <!-- <a-marker type="pattern" url="data/markers/test.patt" markercontroller="name : hiro"></a-marker> -->
20
+
21
+ <a-marker type="pattern" url="data/markers\pi.patt" markercontroller="name : pi"></a-marker>
22
+
23
+ <a-entity camera cameratransform></a-entity>
24
+ </a-scene>
25
+ </body>
26
+ </html>
js/app.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const unityInstance = UnityLoader.instantiate("unityContainer", "Build/Build.json");
2
+ let isCameraReady = false;
3
+ let isDetectionManagerReady = false;
4
+ let gl = null;
5
+
6
+ function cameraReady(){
7
+ isCameraReady = true;
8
+ gl = unityInstance.Module.ctx;
9
+ }
10
+
11
+ function detectionManagerReady(){
12
+ isDetectionManagerReady = true;
13
+ }
14
+
15
+ function createUnityMatrix(el){
16
+ const m = el.matrix.clone();
17
+ const zFlipped = new THREE.Matrix4().makeScale(1, 1, -1).multiply(m);
18
+ const rotated = zFlipped.multiply(new THREE.Matrix4().makeRotationX(-Math.PI/2));
19
+ return rotated;
20
+ }
21
+
22
+ AFRAME.registerComponent('markercontroller', {
23
+ schema: {
24
+ name : {type: 'string'}
25
+ },
26
+ tock: function(time, timeDelta){
27
+
28
+ let position = new THREE.Vector3();
29
+ let rotation = new THREE.Quaternion();
30
+ let scale = new THREE.Vector3();
31
+
32
+ createUnityMatrix(this.el.object3D).decompose(position, rotation, scale);
33
+
34
+ const serializedInfos = `${this.data.name},${this.el.object3D.visible},${position.toArray()},${rotation.toArray()},${scale.toArray()}`;
35
+
36
+ if(isDetectionManagerReady){
37
+ unityInstance.SendMessage("DetectionManager", "markerInfos", serializedInfos);
38
+ }
39
+ }
40
+ });
41
+
42
+ AFRAME.registerComponent('cameratransform', {
43
+ tock: function(time, timeDelta){
44
+
45
+ let camtr = new THREE.Vector3();
46
+ let camro = new THREE.Quaternion();
47
+ let camsc = new THREE.Vector3();
48
+
49
+ this.el.object3D.matrix.clone().decompose(camtr, camro, camsc);
50
+
51
+ const projection = this.el.components.camera.camera.projectionMatrix.clone();
52
+ const serializedProj = `${[...projection.elements]}`
53
+
54
+ const posCam = `${[...camtr.toArray()]}`
55
+ const rotCam = `${[...camro.toArray()]}`
56
+
57
+ if(isCameraReady){
58
+ unityInstance.SendMessage("Main Camera", "setProjection", serializedProj);
59
+ unityInstance.SendMessage("Main Camera", "setPosition", posCam);
60
+ unityInstance.SendMessage("Main Camera", "setRotation", rotCam);
61
+
62
+ let w = window.innerWidth;
63
+ let h = window.innerHeight;
64
+
65
+ const unityCanvas = document.getElementsByTagName('canvas')[0];
66
+
67
+ const ratio = unityCanvas.height / h;
68
+
69
+ w *= ratio
70
+ h *= ratio
71
+
72
+ const size = `${w},${h}`
73
+
74
+ unityInstance.SendMessage("Canvas", "setSize", size);
75
+ }
76
+
77
+ if(gl != null){
78
+ gl.dontClearOnFrameStart = true;
79
+ }
80
+ }
81
+ });
82
+
83
+ AFRAME.registerComponent('copycanvas', {
84
+ tick: function(time, timeDelta){
85
+ const unityCanvas = document.getElementsByTagName('canvas')[0];
86
+ unityCanvas.width = this.el.canvas.width
87
+ unityCanvas.height = this.el.canvas.height
88
+ }
89
+ });
js/lib/aframe-ar.js ADDED
The diff for this file is too large to render. See raw diff
 
js/lib/aframe.min.js ADDED
The diff for this file is too large to render. See raw diff