Skip to content

Commit 111f8a4

Browse files
committed
move VRML stuff out of ::Object into ::VRML
1 parent 01e2080 commit 111f8a4

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

lib/PDL/Graphics/TriD/Object.pm

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package PDL::Graphics::TriD::Object;
33
use strict;
44
use warnings;
55

6-
use fields qw(Objects ValidList ChangedSub List VRML);
6+
use fields qw(Objects ValidList ChangedSub List);
77

88
$PDL::Graphics::TriD::verbose //= 0;
99

1010
sub new{
1111
my $class = shift;
1212
my $self = fields::new($class);
13-
1413
$self;
1514
}
1615

@@ -76,27 +75,4 @@ sub changed {
7675
$_->($this) for @{$this->{ChangedSub}};
7776
}
7877

79-
sub vrml_update {
80-
my ($this) = @_;
81-
use PDL::Graphics::VRML;
82-
83-
$this->{VRML} = PDL::Graphics::VRMLNode->new('Transform',
84-
'translation' => "-1 -1 -1",
85-
'scale' => "2 2 2");
86-
$this->{ValidList} = 1;
87-
}
88-
89-
sub tovrml {
90-
my($this) = @_;
91-
92-
print ref($this)," valid=",$this->{ValidList}," tovrml\n";
93-
94-
if (!$this->{ValidList}) {
95-
$this->vrml_update();
96-
}
97-
$this->{VRML}->add('children',
98-
[map {$_->tovrml()} @{$this->{Objects}}]);
99-
}
100-
101-
10278
1;

lib/PDL/Graphics/TriD/VRML.pm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,24 @@ use base qw/PDL::Graphics::TriD::Object/;
699699
use fields qw/X0 Y0 W H Transformer EHandler Active ResizeCommands
700700
DefMaterial AspectRatio Graphs/;
701701

702+
sub PDL::Graphics::TriD::Object::vrml_update {
703+
my ($this) = @_;
704+
require PDL::Graphics::VRML;
705+
$this->{VRML} = PDL::Graphics::VRMLNode->new('Transform',
706+
'translation' => "-1 -1 -1",
707+
'scale' => "2 2 2");
708+
$this->{ValidList} = 1;
709+
}
702710

703-
711+
sub PDL::Graphics::TriD::Object::tovrml {
712+
my($this) = @_;
713+
print ref($this)," valid=",$this->{ValidList}," tovrml\n";
714+
if (!$this->{ValidList}) {
715+
$this->vrml_update();
716+
}
717+
$this->{VRML}->add('children',
718+
[map {$_->tovrml()} @{$this->{Objects}}]);
719+
}
704720

705721
1;
706722

0 commit comments

Comments
 (0)