Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sphere support to audio-zone #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions addons/io_hubs_addon/components/definitions/audio_zone.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from bpy.props import BoolProperty
from ..gizmos import CustomModelGizmo, bone_matrix_world
from ..models import box
from bpy.props import BoolProperty, EnumProperty
from ..gizmos import CustomModelGizmo, bone_matrix_world, update_gizmos
from ..models import box, sphere
from ..hubs_component import HubsComponent
from ..types import Category, PanelType, NodeType
from .networked import migrate_networked


SHAPES = [("box", "Box", "Box Shape"),
("spehere", "Sphere", "Spehere shape")]


def update_shape(self, context):
update_gizmos()
return None


class AudioZone(HubsComponent):
_definition = {
'name': 'audio-zone',
Expand All @@ -25,6 +34,13 @@ class AudioZone(HubsComponent):
description="The zone audio parameters affect the sources outside the zone when the listener is inside",
default=True)

shape: EnumProperty(name="Shape",
description="Shape of the Audio Zone",
items=SHAPES,
default="box",
update=update_shape
)

@classmethod
def update_gizmo(cls, ob, bone, target, gizmo):
if bone:
Expand All @@ -39,7 +55,8 @@ def update_gizmo(cls, ob, bone, target, gizmo):
def create_gizmo(cls, ob, gizmo_group):
gizmo = gizmo_group.gizmos.new(CustomModelGizmo.bl_idname)
gizmo.object = ob
setattr(gizmo, "hubs_gizmo_shape", box.SHAPE)
shape = box.SHAPE if ob.hubs_component_audio_zone.shape == "box" else sphere.SHAPE
setattr(gizmo, "hubs_gizmo_shape", shape)
gizmo.setup()
gizmo.use_draw_scale = False
gizmo.use_draw_modal = False
Expand Down
1 change: 1 addition & 0 deletions addons/io_hubs_addon/components/models/sphere.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/test/test_export.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ describe('Exporter', function () {
const ext = node.extensions['MOZ_hubs_components'];
assert.deepStrictEqual(ext["audio-zone"], {
"inOut": true,
"outIn": true
"outIn": true,
"shape": "box"
});
assert.deepStrictEqual(ext["audio-params"], {
"audioType": "pannernode",
Expand Down