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
e5efb442
Commit
e5efb442
authored
6 years ago
by
Marshall Quander
Browse files
Options
Downloads
Patches
Plain Diff
Don't require entities for IK controller
parent
986a694a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/ik-controller.js
+27
-32
27 additions, 32 deletions
src/components/ik-controller.js
src/hub.html
+0
-21
0 additions, 21 deletions
src/hub.html
with
27 additions
and
53 deletions
src/components/ik-controller.js
+
27
−
32
View file @
e5efb442
...
...
@@ -39,14 +39,14 @@ function findIKRoot(entity) {
*/
AFRAME
.
registerComponent
(
"
ik-controller
"
,
{
schema
:
{
leftEye
:
{
type
:
"
string
"
,
default
:
"
.
LeftEye
"
},
rightEye
:
{
type
:
"
string
"
,
default
:
"
.
RightEye
"
},
head
:
{
type
:
"
string
"
,
default
:
"
.
Head
"
},
neck
:
{
type
:
"
string
"
,
default
:
"
.
Neck
"
},
leftHand
:
{
type
:
"
string
"
,
default
:
"
.
LeftHand
"
},
rightHand
:
{
type
:
"
string
"
,
default
:
"
.
RightHand
"
},
chest
:
{
type
:
"
string
"
,
default
:
"
.
Chest
"
},
hips
:
{
type
:
"
string
"
,
default
:
"
.
Hips
"
},
leftEye
:
{
type
:
"
string
"
,
default
:
"
LeftEye
"
},
rightEye
:
{
type
:
"
string
"
,
default
:
"
RightEye
"
},
head
:
{
type
:
"
string
"
,
default
:
"
Head
"
},
neck
:
{
type
:
"
string
"
,
default
:
"
Neck
"
},
leftHand
:
{
type
:
"
string
"
,
default
:
"
LeftHand
"
},
rightHand
:
{
type
:
"
string
"
,
default
:
"
RightHand
"
},
chest
:
{
type
:
"
string
"
,
default
:
"
Chest
"
},
hips
:
{
type
:
"
string
"
,
default
:
"
Hips
"
},
rotationSpeed
:
{
default
:
5
}
},
...
...
@@ -86,46 +86,46 @@ AFRAME.registerComponent("ik-controller", {
update
(
oldData
)
{
if
(
this
.
data
.
leftEye
!==
oldData
.
leftEye
)
{
this
.
leftEye
=
this
.
el
.
querySelector
(
this
.
data
.
leftEye
);
this
.
leftEye
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
leftEye
);
}
if
(
this
.
data
.
rightEye
!==
oldData
.
rightEye
)
{
this
.
rightEye
=
this
.
el
.
querySelector
(
this
.
data
.
rightEye
);
this
.
rightEye
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
rightEye
);
}
if
(
this
.
data
.
head
!==
oldData
.
head
)
{
this
.
head
=
this
.
el
.
querySelector
(
this
.
data
.
head
);
this
.
head
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
head
);
}
if
(
this
.
data
.
neck
!==
oldData
.
neck
)
{
this
.
neck
=
this
.
el
.
querySelector
(
this
.
data
.
neck
);
this
.
neck
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
neck
);
}
if
(
this
.
data
.
leftHand
!==
oldData
.
leftHand
)
{
this
.
leftHand
=
this
.
el
.
querySelector
(
this
.
data
.
leftHand
);
this
.
leftHand
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
leftHand
);
}
if
(
this
.
data
.
rightHand
!==
oldData
.
rightHand
)
{
this
.
rightHand
=
this
.
el
.
querySelector
(
this
.
data
.
rightHand
);
this
.
rightHand
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
rightHand
);
}
if
(
this
.
data
.
chest
!==
oldData
.
chest
)
{
this
.
chest
=
this
.
el
.
querySelector
(
this
.
data
.
chest
);
this
.
chest
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
chest
);
}
if
(
this
.
data
.
hips
!==
oldData
.
hips
)
{
this
.
hips
=
this
.
el
.
querySelector
(
this
.
data
.
hips
);
this
.
hips
=
this
.
el
.
object3D
.
getObjectByName
(
this
.
data
.
hips
);
}
// Set middleEye's position to be right in the middle of the left and right eyes.
this
.
middleEyePosition
.
addVectors
(
this
.
leftEye
.
object3D
.
position
,
this
.
rightEye
.
object3D
.
position
);
this
.
middleEyePosition
.
addVectors
(
this
.
leftEye
.
position
,
this
.
rightEye
.
position
);
this
.
middleEyePosition
.
divideScalar
(
2
);
this
.
middleEyeMatrix
.
makeTranslation
(
this
.
middleEyePosition
.
x
,
this
.
middleEyePosition
.
y
,
this
.
middleEyePosition
.
z
);
this
.
invMiddleEyeToHead
=
this
.
middleEyeMatrix
.
getInverse
(
this
.
middleEyeMatrix
);
this
.
invHipsToHeadVector
.
addVectors
(
this
.
chest
.
object3D
.
position
,
this
.
neck
.
object3D
.
position
)
.
add
(
this
.
head
.
object3D
.
position
)
.
addVectors
(
this
.
chest
.
position
,
this
.
neck
.
position
)
.
add
(
this
.
head
.
position
)
.
negate
();
},
...
...
@@ -162,35 +162,30 @@ AFRAME.registerComponent("ik-controller", {
// Then position the hips such that the head is aligned with headTransform
// (which positions middleEye in line with the hmd)
hips
.
object3D
.
position
.
setFromMatrixPosition
(
headTransform
).
add
(
invHipsToHeadVector
);
hips
.
position
.
setFromMatrixPosition
(
headTransform
).
add
(
invHipsToHeadVector
);
// Animate the hip rotation to follow the Y rotation of the camera with some damping.
cameraYRotation
.
setFromRotationMatrix
(
cameraForward
,
"
YXZ
"
);
cameraYRotation
.
x
=
0
;
cameraYRotation
.
z
=
0
;
cameraYQuaternion
.
setFromEuler
(
cameraYRotation
);
Quaternion
.
slerp
(
hips
.
object3D
.
quaternion
,
cameraYQuaternion
,
hips
.
object3D
.
quaternion
,
this
.
data
.
rotationSpeed
*
dt
/
1000
);
Quaternion
.
slerp
(
hips
.
quaternion
,
cameraYQuaternion
,
hips
.
quaternion
,
this
.
data
.
rotationSpeed
*
dt
/
1000
);
// Take the head orientation computed from the hmd, remove the Y rotation already applied to it by the hips,
// and apply it to the head
invHipsQuaternion
.
copy
(
hips
.
object3D
.
quaternion
).
inverse
();
head
.
object3D
.
quaternion
.
setFromRotationMatrix
(
headTransform
).
premultiply
(
invHipsQuaternion
);
invHipsQuaternion
.
copy
(
hips
.
quaternion
).
inverse
();
head
.
quaternion
.
setFromRotationMatrix
(
headTransform
).
premultiply
(
invHipsQuaternion
);
hips
.
object3D
.
updateMatrix
();
rootToChest
.
multiplyMatrices
(
hips
.
object3D
.
matrix
,
chest
.
object3D
.
matrix
);
hips
.
updateMatrix
();
rootToChest
.
multiplyMatrices
(
hips
.
matrix
,
chest
.
matrix
);
invRootToChest
.
getInverse
(
rootToChest
);
this
.
updateHand
(
this
.
hands
.
left
,
leftHand
,
leftController
);
this
.
updateHand
(
this
.
hands
.
right
,
rightHand
,
rightController
);
},
updateHand
(
handState
,
hand
,
controller
)
{
const
hand
Object3D
=
hand
.
o
bject3D
;
updateHand
(
handState
,
hand
Object3D
,
controller
)
{
const
hand
=
hand
O
bject3D
.
el
;
const
handMatrix
=
handObject3D
.
matrix
;
const
controllerObject3D
=
controller
.
object3D
;
...
...
This diff is collapsed.
Click to expand it.
src/hub.html
+
0
−
21
View file @
e5efb442
...
...
@@ -148,16 +148,6 @@
<a-entity></a-entity>
</template>
<!-- needs to exist for the benefit of the IK calculation -->
<template
data-name=
"LeftEye"
>
<a-entity></a-entity>
</template>
<!-- needs to exist for the benefit of the IK calculation -->
<template
data-name=
"RightEye"
>
<a-entity></a-entity>
</template>
<template
data-name=
"LeftHand"
>
<a-entity
personal-space-invader=
"radius: 0.1"
bone-visibility
></a-entity>
</template>
...
...
@@ -402,17 +392,6 @@
</a-entity>
</template>
<!-- needs to exist for the benefit of the IK calculation -->
<template
data-name=
"LeftEye"
>
<a-entity></a-entity>
</template>
<!-- needs to exist for the benefit of the IK calculation -->
<template
data-name=
"RightEye"
>
<a-entity></a-entity>
</template>
<template
data-name=
"Head"
>
<a-entity
visible=
"false"
bone-visibility
></a-entity>
</template>
...
...
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