Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
3a7c5f52
Commit
3a7c5f52
authored
6 years ago
by
netpro2k
Browse files
Options
Downloads
Patches
Plain Diff
New camera tool model, 16:9 aspect ratio, don't unfreeze taken photos
parent
bd9ea4f5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/assets/camera_tool.glb
+0
-0
0 additions, 0 deletions
src/assets/camera_tool.glb
src/components/camera-tool.js
+26
-21
26 additions, 21 deletions
src/components/camera-tool.js
src/hub.html
+1
-1
1 addition, 1 deletion
src/hub.html
with
27 additions
and
22 deletions
src/assets/camera_tool.glb
0 → 100644
+
0
−
0
View file @
3a7c5f52
File added
This diff is collapsed.
Click to expand it.
src/components/camera-tool.js
+
26
−
21
View file @
3a7c5f52
import
{
addMedia
}
from
"
../utils/media-utils
"
;
import
{
addMedia
}
from
"
../utils/media-utils
"
;
import
{
ObjectTypes
}
from
"
../object-types
"
;
import
{
ObjectTypes
}
from
"
../object-types
"
;
import
cameraModelSrc
from
"
../assets/camera_tool.glb
"
;
const
cameraModelPromise
=
new
Promise
(
resolve
=>
new
THREE
.
GLTFLoader
().
load
(
cameraModelSrc
,
resolve
));
const
snapCanvas
=
document
.
createElement
(
"
canvas
"
);
const
snapCanvas
=
document
.
createElement
(
"
canvas
"
);
async
function
pixelsToPNG
(
pixels
,
width
,
height
)
{
async
function
pixelsToPNG
(
pixels
,
width
,
height
)
{
snapCanvas
.
width
=
width
;
snapCanvas
.
width
=
width
;
...
@@ -19,8 +23,8 @@ async function pixelsToPNG(pixels, width, height) {
...
@@ -19,8 +23,8 @@ async function pixelsToPNG(pixels, width, height) {
AFRAME
.
registerComponent
(
"
camera-tool
"
,
{
AFRAME
.
registerComponent
(
"
camera-tool
"
,
{
schema
:
{
schema
:
{
previewFPS
:
{
default
:
6
},
previewFPS
:
{
default
:
6
},
imageWidth
:
{
default
:
512
},
imageWidth
:
{
default
:
1024
},
imageHeight
:
{
default
:
512
}
imageHeight
:
{
default
:
1024
/
(
16
/
9
)
}
},
},
init
()
{
init
()
{
...
@@ -37,13 +41,14 @@ AFRAME.registerComponent("camera-tool", {
...
@@ -37,13 +41,14 @@ AFRAME.registerComponent("camera-tool", {
stencil
:
false
stencil
:
false
});
});
this
.
camera
=
new
THREE
.
PerspectiveCamera
();
this
.
camera
=
new
THREE
.
PerspectiveCamera
(
50
,
this
.
renderTarget
.
width
/
this
.
renderTarget
.
height
,
0.1
,
30000
);
this
.
camera
.
rotation
.
set
(
0
,
Math
.
PI
,
0
);
this
.
camera
.
rotation
.
set
(
0
,
Math
.
PI
,
0
);
this
.
el
.
setObject3D
(
"
camera
"
,
this
.
camera
);
this
.
el
.
setObject3D
(
"
camera
"
,
this
.
camera
);
const
material
=
new
THREE
.
MeshBasicMaterial
({
const
material
=
new
THREE
.
MeshBasicMaterial
({
map
:
this
.
renderTarget
.
texture
map
:
this
.
renderTarget
.
texture
});
});
// Bit of a hack here to only update the renderTarget when the screens are in view and at a reduced FPS
// Bit of a hack here to only update the renderTarget when the screens are in view and at a reduced FPS
material
.
map
.
isVideoTexture
=
true
;
material
.
map
.
isVideoTexture
=
true
;
material
.
map
.
update
=
()
=>
{
material
.
map
.
update
=
()
=>
{
...
@@ -52,25 +57,26 @@ AFRAME.registerComponent("camera-tool", {
...
@@ -52,25 +57,26 @@ AFRAME.registerComponent("camera-tool", {
}
}
};
};
this
.
el
.
addEventListener
(
cameraModelPromise
.
then
(
model
=>
{
"
model-loaded
"
,
const
mesh
=
model
.
scene
.
clone
();
()
=>
{
mesh
.
scale
.
set
(
2
,
2
,
2
);
const
geometry
=
new
THREE
.
PlaneGeometry
(
0.25
,
0.25
);
this
.
el
.
setObject3D
(
"
mesh
"
,
mesh
);
const
screen
=
new
THREE
.
Mesh
(
geometry
,
material
);
const
width
=
0.28
;
screen
.
rotation
.
set
(
0
,
Math
.
PI
,
0
);
const
geometry
=
new
THREE
.
PlaneGeometry
(
width
,
width
/
this
.
camera
.
aspect
);
screen
.
position
.
set
(
0
,
-
0.015
,
-
0.08
);
this
.
el
.
setObject3D
(
"
screen
"
,
screen
);
const
s
elfieS
creen
=
new
THREE
.
Mesh
(
geometry
,
material
);
const
screen
=
new
THREE
.
Mesh
(
geometry
,
material
);
selfieS
creen
.
posi
tion
.
set
(
0
,
0.3
,
0
);
s
creen
.
rota
tion
.
set
(
0
,
Math
.
PI
,
0
);
selfieScreen
.
scale
.
set
(
-
1
,
1
,
1
);
screen
.
position
.
set
(
0
,
0
,
-
0.042
);
this
.
el
.
setObject3D
(
"
s
elfieS
creen
"
,
s
elfieS
creen
);
this
.
el
.
setObject3D
(
"
screen
"
,
screen
);
this
.
updateRenderTargetNextTick
=
true
;
const
selfieScreen
=
new
THREE
.
Mesh
(
geometry
,
material
);
},
selfieScreen
.
position
.
set
(
0
,
0.4
,
0
);
{
once
:
true
}
selfieScreen
.
scale
.
set
(
-
2
,
2
,
2
);
);
this
.
el
.
setObject3D
(
"
selfieScreen
"
,
selfieScreen
);
this
.
updateRenderTargetNextTick
=
true
;
});
},
},
play
()
{
play
()
{
...
@@ -128,9 +134,8 @@ AFRAME.registerComponent("camera-tool", {
...
@@ -128,9 +134,8 @@ AFRAME.registerComponent("camera-tool", {
pixelsToPNG
(
this
.
snapPixels
,
width
,
height
).
then
(
file
=>
{
pixelsToPNG
(
this
.
snapPixels
,
width
,
height
).
then
(
file
=>
{
const
{
entity
,
orientation
}
=
addMedia
(
file
,
"
#interactable-media
"
,
undefined
,
true
);
const
{
entity
,
orientation
}
=
addMedia
(
file
,
"
#interactable-media
"
,
undefined
,
true
);
orientation
.
then
(()
=>
{
orientation
.
then
(()
=>
{
entity
.
object3D
.
position
.
copy
(
this
.
el
.
object3D
.
position
);
entity
.
object3D
.
position
.
copy
(
this
.
el
.
object3D
.
position
)
.
add
(
new
THREE
.
Vector3
(
0
,
-
0.5
,
0
))
;
entity
.
object3D
.
rotation
.
copy
(
this
.
el
.
object3D
.
rotation
);
entity
.
object3D
.
rotation
.
copy
(
this
.
el
.
object3D
.
rotation
);
entity
.
components
[
"
sticky-object
"
].
setLocked
(
false
);
sceneEl
.
emit
(
"
object_spawned
"
,
{
objectType
:
ObjectTypes
.
CAMERA
});
sceneEl
.
emit
(
"
object_spawned
"
,
{
objectType
:
ObjectTypes
.
CAMERA
});
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
src/hub.html
+
1
−
1
View file @
3a7c5f52
...
@@ -212,8 +212,8 @@
...
@@ -212,8 +212,8 @@
activatable__snap-cursor=
"buttonStartEvents: secondary-cursor-grab; buttonEndEvents: secondary-cursor-release;"
activatable__snap-cursor=
"buttonStartEvents: secondary-cursor-grab; buttonEndEvents: secondary-cursor-release;"
camera-tool
camera-tool
body=
"type: dynamic; shape: none; mass: 1;"
body=
"type: dynamic; shape: none; mass: 1;"
shape=
"shape: box; halfExtents: 0.22 0.145 0.1; offset: 0 0.02 0"
sticky-object=
"autoLockOnRelease: true; autoLockOnLoad: true;"
sticky-object=
"autoLockOnRelease: true; autoLockOnLoad: true;"
media-loader=
"src: https://sketchfab.com/models/2e8778db90e845888e38edd80be28283; resize: true"
super-networked-interactable=
"counter: #camera-counter;"
super-networked-interactable=
"counter: #camera-counter;"
position-at-box-shape-border=
"target:.delete-button"
position-at-box-shape-border=
"target:.delete-button"
rotation
rotation
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment