AFrame:物理问题; dynamic-body & 可抓取
AFrame: Problem with physics; dynamic-body & grabbable
问题:
我想制作一个用户可以扔的球。在我目前的实施中,物理可以工作,但我不能举起球。但是,如果我删除“dynamic-body”,我就可以准确地抓住球,然后四处移动。哎呀,我试着把它改成“static-body”,它仍然有效。问题似乎是每当我将 grabbable 和 dynamic-body 混合使用时。我知道在旧版本中应该是可能的,因为我正在使用本教程:https://www.youtube.com/watch?v=SKYfYd3pk4I
但是,他正在使用最新的 super-hands 软件包中没有的 progressive-controls,我不知道这是否会改变什么。我这里有什么地方做错了吗?
以下是我可能会影响结果的代码片段:
我的 A-Frame 包:
<head>
<!-- A-Frame -->
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<!-- A-Frame Components -->
<!-- A-Frame Particle System -->
<script src="https://unpkg.com/aframe-particle-system-component@1.0.9/dist/aframe-particle-system-component.min.js"></script>
<script src="https://unpkg.com/aframe-environment-component/dist/aframe-environment-component.min.js"></script>
<!-- A-Frame Event System -->
<script src="https://unpkg.com/aframe-event-set-component@4.2.1/dist/aframe-event-set-component.min.js"></script>
<!-- A-Frame Extras Add-Ons -->
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
<!-- A-Frame Physics -->
<script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-physics-system@v4.0.1/dist/aframe-physics-system.min.js"></script>
<!-- A-Frame Physics Extra Add-On -->
<script src="https://unpkg.com/aframe-physics-extras@0.1.2/dist/aframe-physics-extras.min.js"></script>
<!-- A-Frame Super Hands -->
<script src="https://unpkg.com/super-hands@3.0.0/dist/super-hands.min.js"></script>
</head>
我的问题领域:
<!-- Ball -->
<a-entity
id="Ball-2"
position="0 0 0">
<a-sphere
id="Ball-2-collider"
grabbable
dynamic-body="mass: 0.2; linearDamping: 0.05; angularDamping: 0.3; shape: sphere;
sphereRadius: 0.125;"
class="interactable ball"
radius="5"
position="0 0.6 3.8"
scale="0.02 0.02 0.02">
<a-entity
id="ball-2-mesh"
position="0 -6 0"
rotation="0 0 0"
scale="600 600 600"
gltf-model="#Ball-glb"
color="#FFFFFF">
</a-entity>
</a-sphere>
</a-entity>
我的controller-setup:
<a-entity id="camera-rig" position="0 -1.20 4" rotation="0 150 0">
<a-camera
user-height="1.6"
active="true">
<a-entity
cursor="fuse: true; fuseTimeout: 1000"
raycaster="objects: .interactable"
animation__fusing="property: scale; startEvents: fusing; easing: linear; dur: 1000; from: 1 1 1; to: 3 3 3"
animation__leave="property: scale; startEvents: mouseleave; easing: linear; dur: 1; from: 1 1 1; to: 1 1 1"
animation__click="property: scale; startEvents: click; easing: linear; dur: 150; from: 3 3 3; to: 1 1 1"
position="0 0 -1"
geometry="primitive: sphere; radius: 0.005"
material="color: #FF00FF; shader: flat; opacity: 0.5">
</a-entity>
</a-camera>
<a-entity sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: left"></a-entity>
<a-entity sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: right"></a-entity>
</a-entity>
最后,a-scene定义引力:
<a-scene embedded antialias="false" physics="gravity: -9.8; debug: true">
多亏了这个:https://github.com/bryik/aframe-ball-throw/blob/master/index.html
我找到了罪魁祸首。
我需要将静态体添加到我的手实体中,以便可以检测到碰撞。不知道为什么之前没有它们会检测到碰撞。
修改后的代码:
<a-entity static-body="shape: sphere; sphereRadius: 0.02;" sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: left"></a-entity>
<a-entity static-body="shape: sphere; sphereRadius: 0.02;" sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: right"></a-entity>
问题:
我想制作一个用户可以扔的球。在我目前的实施中,物理可以工作,但我不能举起球。但是,如果我删除“dynamic-body”,我就可以准确地抓住球,然后四处移动。哎呀,我试着把它改成“static-body”,它仍然有效。问题似乎是每当我将 grabbable 和 dynamic-body 混合使用时。我知道在旧版本中应该是可能的,因为我正在使用本教程:https://www.youtube.com/watch?v=SKYfYd3pk4I
但是,他正在使用最新的 super-hands 软件包中没有的 progressive-controls,我不知道这是否会改变什么。我这里有什么地方做错了吗?
以下是我可能会影响结果的代码片段:
我的 A-Frame 包:
<head>
<!-- A-Frame -->
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<!-- A-Frame Components -->
<!-- A-Frame Particle System -->
<script src="https://unpkg.com/aframe-particle-system-component@1.0.9/dist/aframe-particle-system-component.min.js"></script>
<script src="https://unpkg.com/aframe-environment-component/dist/aframe-environment-component.min.js"></script>
<!-- A-Frame Event System -->
<script src="https://unpkg.com/aframe-event-set-component@4.2.1/dist/aframe-event-set-component.min.js"></script>
<!-- A-Frame Extras Add-Ons -->
<script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
<!-- A-Frame Physics -->
<script src="https://cdn.jsdelivr.net/gh/n5ro/aframe-physics-system@v4.0.1/dist/aframe-physics-system.min.js"></script>
<!-- A-Frame Physics Extra Add-On -->
<script src="https://unpkg.com/aframe-physics-extras@0.1.2/dist/aframe-physics-extras.min.js"></script>
<!-- A-Frame Super Hands -->
<script src="https://unpkg.com/super-hands@3.0.0/dist/super-hands.min.js"></script>
</head>
我的问题领域:
<!-- Ball -->
<a-entity
id="Ball-2"
position="0 0 0">
<a-sphere
id="Ball-2-collider"
grabbable
dynamic-body="mass: 0.2; linearDamping: 0.05; angularDamping: 0.3; shape: sphere;
sphereRadius: 0.125;"
class="interactable ball"
radius="5"
position="0 0.6 3.8"
scale="0.02 0.02 0.02">
<a-entity
id="ball-2-mesh"
position="0 -6 0"
rotation="0 0 0"
scale="600 600 600"
gltf-model="#Ball-glb"
color="#FFFFFF">
</a-entity>
</a-sphere>
</a-entity>
我的controller-setup:
<a-entity id="camera-rig" position="0 -1.20 4" rotation="0 150 0">
<a-camera
user-height="1.6"
active="true">
<a-entity
cursor="fuse: true; fuseTimeout: 1000"
raycaster="objects: .interactable"
animation__fusing="property: scale; startEvents: fusing; easing: linear; dur: 1000; from: 1 1 1; to: 3 3 3"
animation__leave="property: scale; startEvents: mouseleave; easing: linear; dur: 1; from: 1 1 1; to: 1 1 1"
animation__click="property: scale; startEvents: click; easing: linear; dur: 150; from: 3 3 3; to: 1 1 1"
position="0 0 -1"
geometry="primitive: sphere; radius: 0.005"
material="color: #FF00FF; shader: flat; opacity: 0.5">
</a-entity>
</a-camera>
<a-entity sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: left"></a-entity>
<a-entity sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: right"></a-entity>
</a-entity>
最后,a-scene定义引力:
<a-scene embedded antialias="false" physics="gravity: -9.8; debug: true">
多亏了这个:https://github.com/bryik/aframe-ball-throw/blob/master/index.html
我找到了罪魁祸首。 我需要将静态体添加到我的手实体中,以便可以检测到碰撞。不知道为什么之前没有它们会检测到碰撞。
修改后的代码:
<a-entity static-body="shape: sphere; sphereRadius: 0.02;" sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: left"></a-entity>
<a-entity static-body="shape: sphere; sphereRadius: 0.02;" sphere-collider="objects: .interactable" handModelStyle: lowPoly; super-hands hand-controls="hand: right"></a-entity>